Skip to content

Commit 71a3540

Browse files
authored
Merge pull request #29 from harveyhq/feature/issue-45
Feature/issue 45
2 parents cf5ba15 + 0d5f2fa commit 71a3540

File tree

9 files changed

+4263
-2103
lines changed

9 files changed

+4263
-2103
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[*]
22
charset=utf-8
3-
end_of_line=lf
3+
end_of_line=crlf
44
trim_trailing_whitespace=true
55
insert_final_newline=true
66
indent_style=space

.eslintrc.json

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22
"env": {
33
"commonjs": true,
44
"es2021": true,
5-
"node": true
5+
"node": true,
6+
"jest": true
67
},
78
"extends": ["eslint:recommended"],
89
"parserOptions": {
910
"ecmaVersion": 2021
1011
},
12+
"overrides": [
13+
{
14+
"files": ["__tests__/*.spec.js"], // Or *.test.js
15+
"rules": {
16+
"strict": ["warn", "safe"]
17+
}
18+
}
19+
],
1120
"rules": {
1221
"strict": ["error", "global"],
1322
"no-await-in-loop": "warn",
@@ -86,11 +95,7 @@
8695
"array-bracket-spacing": "error",
8796
"block-spacing": "error",
8897
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
89-
"capitalized-comments": [
90-
"error",
91-
"always",
92-
{ "ignoreConsecutiveComments": true }
93-
],
98+
"capitalized-comments": ["error", "always", { "ignoreConsecutiveComments": true }],
9499
"comma-dangle": ["error", "always-multiline"],
95100
"comma-spacing": "error",
96101
"comma-style": "error",
@@ -111,10 +116,7 @@
111116
"no-array-constructor": "error",
112117
"no-inline-comments": "error",
113118
"no-lonely-if": "error",
114-
"no-multiple-empty-lines": [
115-
"error",
116-
{ "max": 2, "maxEOF": 1, "maxBOF": 0 }
117-
],
119+
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
118120
"no-new-object": "error",
119121
"no-spaced-func": "error",
120122
"no-trailing-spaces": "error",
@@ -125,11 +127,7 @@
125127
"operator-assignment": "error",
126128
"padded-blocks": ["error", "never"],
127129
"quote-props": ["error", "as-needed"],
128-
"quotes": [
129-
"error",
130-
"single",
131-
{ "avoidEscape": true, "allowTemplateLiterals": true }
132-
],
130+
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
133131
"semi-spacing": "error",
134132
"semi": "error",
135133
"space-before-blocks": "error",

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [12.x, 14.x, 16.x]
19+
node-version: [16.x, 18.x]
2020
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2121

2222
steps:

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
public
3+
coverage

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 4,
4+
"semi": true,
5+
"singleQuote": true,
6+
"bracketSameLine": true,
7+
"printWidth": 140,
8+
"arrowParens": "avoid",
9+
"endOfLine": "crlf"
10+
}
11+

__tests__/index.spec.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
const { toUpper:upper, decorateToUpper } = require("../src/index");
1+
'use strict';
22

3-
describe("Test some function", () => {
4-
// test
5-
test("it should make string uppercased", () => {
6-
expect(upper("UnIcOrNs")).toEqual("UNICORNS");
3+
const lib = require('../src/index');
4+
5+
const { toUpper, decorateToUpper, capitalize } = lib;
6+
7+
describe('Test some function', () => {
8+
// Test
9+
test('it should make string uppercased', () => {
10+
expect(toUpper('UnIcOrNs')).toEqual('UNICORNS');
11+
});
12+
13+
test('it should make string uppercased and append [decorated] to the end', () => {
14+
expect(decorateToUpper('UnIcOrNs')).toEqual('UNICORNS [decorated]');
715
});
816

9-
test("it should make string uppercased and append [decorated] to the end", () => {
10-
expect(decorateToUpper("UnIcOrNs")).toEqual("UNICORNS [decorated]");
17+
test('mock toUpper()', () => {
18+
const fakeToUpper = jest.spyOn(lib, 'toUpper').mockReturnValue('AAA');
19+
expect(fakeToUpper('ccc')).toBe('AAA');
1120
});
1221

13-
test("mock toUpper()", () => {
14-
const f = require("../src/index");
15-
jest.spyOn(f, 'toUpper').mockReturnValue('ccc');
16-
expect(f.decorateToUpper('aaa')).toBe('ccc [decorated]');
22+
test('it should mke string capitalized', () => {
23+
expect(capitalize('aRiNa')).toBe('Arina');
1724
});
1825
});

0 commit comments

Comments
 (0)