Skip to content

Commit 1870a6a

Browse files
authored
Merge pull request #13 from hckrnews/feature/20231020
Update dependencies
2 parents ff8ea6e + c32c6de commit 1870a6a

7 files changed

+324
-306
lines changed

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.13.0
1+
20.10.0

babel.config.cjs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module.exports = {
2-
presets: [
3-
[
4-
'@babel/preset-env',
5-
{
6-
targets: {
7-
node: true,
8-
},
9-
},
10-
],
11-
],
12-
plugins: ['@babel/plugin-transform-modules-commonjs'],
13-
};
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: {
7+
node: true
8+
}
9+
}
10+
]
11+
],
12+
plugins: ['@babel/plugin-transform-modules-commonjs']
13+
}

jsconfig.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"checkJs": true,
4+
"target": "ESNext",
5+
"module": "NodeNext",
6+
"moduleResolution": "nodenext",
7+
"rootDirs": [
8+
"src"
9+
],
10+
"resolveJsonModule": true
11+
},
12+
"exclude": [
13+
"node_modules",
14+
"**/node_modules/*"
15+
]
16+
}

package-lock.json

+155-154
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@hckrnews/mutator",
33
"description": "Mutate the value when set some data",
4-
"version": "0.3.4",
4+
"version": "0.3.5",
55
"author": {
66
"name": "Pieter Wigboldus",
77
"url": "https://hckr.news/"
@@ -10,6 +10,7 @@
1010
"scripts": {
1111
"lint": "eslint src/*.js --config .eslintrc",
1212
"lint:fix": "eslint src/*.js --config .eslintrc --fix",
13+
"lint:report": "eslint src/*.js --config .eslintrc -f json -o report.json",
1314
"test": "jest",
1415
"test:watch": "jest src --watch",
1516
"coveralls": "jest && codecov && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",

src/__tests__/default.unit.js

+107-107
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,125 @@
1-
import { expect, describe, it } from '@jest/globals';
2-
import DefaultMutator from '../default.js';
1+
import { expect, describe, it } from '@jest/globals'
2+
import DefaultMutator from '../default.js'
33

44
class ExampleMutator extends DefaultMutator {
5-
setSkuAttribute(sku) {
6-
return `*${sku}*`;
7-
}
5+
setSkuAttribute (sku) {
6+
return `*${sku}*`
7+
}
88

9-
setProductGroupAttribute(productGroup) {
10-
return `*${productGroup}*`;
11-
}
9+
setProductGroupAttribute (productGroup) {
10+
return `*${productGroup}*`
11+
}
1212

13-
setSubTestAttribute(value) {
14-
return `*${value}*`;
15-
}
13+
setSubTestAttribute (value) {
14+
return `*${value}*`
15+
}
1616

17-
setSubFirstAttribute(value) {
18-
return value;
19-
}
17+
setSubFirstAttribute (value) {
18+
return value
19+
}
2020

21-
setSubLastAttribute(value) {
22-
return value;
23-
}
21+
setSubLastAttribute (value) {
22+
return value
23+
}
2424
}
2525

2626
describe('Test the filter mutator', () => {
27-
it('It should skip empty values', () => {
28-
const result = DefaultMutator.create({
29-
test: 'ok',
30-
test2: null,
31-
test3: undefined,
32-
test4: NaN,
33-
test5: false,
34-
test6: 0,
35-
test7: 1,
36-
});
37-
expect({ ...result }).toEqual({
38-
test: 'ok',
39-
test5: false,
40-
test6: 0,
41-
test7: 1,
42-
});
43-
});
27+
it('It should skip empty values', () => {
28+
const result = DefaultMutator.create({
29+
test: 'ok',
30+
test2: null,
31+
test3: undefined,
32+
test4: NaN,
33+
test5: false,
34+
test6: 0,
35+
test7: 1
36+
})
37+
expect({ ...result }).toEqual({
38+
test: 'ok',
39+
test5: false,
40+
test6: 0,
41+
test7: 1
42+
})
43+
})
4444

45-
it('It should set the item', () => {
46-
const result = ExampleMutator.create({ sku: 42, test: 'ok' });
47-
expect({ ...result }).toEqual({ sku: '*42*', test: 'ok' });
48-
});
45+
it('It should set the item', () => {
46+
const result = ExampleMutator.create({ sku: 42, test: 'ok' })
47+
expect({ ...result }).toEqual({ sku: '*42*', test: 'ok' })
48+
})
4949

50-
it('It should set the item only if the value isnt null', () => {
51-
const result = ExampleMutator.create({
52-
sku: null,
53-
test: 'ok',
54-
test2: null,
55-
});
56-
expect({ ...result }).toEqual({ test: 'ok' });
57-
});
50+
it('It should set the item only if the value isnt null', () => {
51+
const result = ExampleMutator.create({
52+
sku: null,
53+
test: 'ok',
54+
test2: null
55+
})
56+
expect({ ...result }).toEqual({ test: 'ok' })
57+
})
5858

59-
it('It should only call a setter', () => {
60-
const result = ExampleMutator.create({ sku: 42 });
61-
expect({ ...result }).toEqual({ sku: '*42*' });
62-
});
59+
it('It should only call a setter', () => {
60+
const result = ExampleMutator.create({ sku: 42 })
61+
expect({ ...result }).toEqual({ sku: '*42*' })
62+
})
6363

64-
it('It should handle the product.group', () => {
65-
const result = ExampleMutator.create({ product: { group: 'test' } });
66-
expect({ ...result }).toEqual({ product: { group: '*test*' } });
67-
});
64+
it('It should handle the product.group', () => {
65+
const result = ExampleMutator.create({ product: { group: 'test' } })
66+
expect({ ...result }).toEqual({ product: { group: '*test*' } })
67+
})
6868

69-
it('It should handle the product_group', () => {
70-
const result = ExampleMutator.create({ product_group: 'test' });
71-
expect({ ...result }).toEqual({ product_group: '*test*' });
72-
});
69+
it('It should handle the product_group', () => {
70+
const result = ExampleMutator.create({ product_group: 'test' })
71+
expect({ ...result }).toEqual({ product_group: '*test*' })
72+
})
7373

74-
it('It should not call a setter', () => {
75-
const result = ExampleMutator.create({ test: 'ok', test2: 'also ok' });
76-
expect({ ...result }).toEqual({ test: 'ok', test2: 'also ok' });
77-
});
74+
it('It should not call a setter', () => {
75+
const result = ExampleMutator.create({ test: 'ok', test2: 'also ok' })
76+
expect({ ...result }).toEqual({ test: 'ok', test2: 'also ok' })
77+
})
7878

79-
it('It should hydrate the object with new data', () => {
80-
const result = ExampleMutator.create({ test: 'ok', test2: 'also ok' });
81-
expect({ ...result }).toEqual({ test: 'ok', test2: 'also ok' });
82-
result.hydrate({ sku: 43 });
83-
expect({ ...result }).toEqual({
84-
sku: '*43*',
85-
test: 'ok',
86-
test2: 'also ok',
87-
});
88-
result.hydrate({ test: 'another text' });
89-
expect({ ...result }).toEqual({
90-
sku: '*43*',
91-
test: 'another text',
92-
test2: 'also ok',
93-
});
94-
});
79+
it('It should hydrate the object with new data', () => {
80+
const result = ExampleMutator.create({ test: 'ok', test2: 'also ok' })
81+
expect({ ...result }).toEqual({ test: 'ok', test2: 'also ok' })
82+
result.hydrate({ sku: 43 })
83+
expect({ ...result }).toEqual({
84+
sku: '*43*',
85+
test: 'ok',
86+
test2: 'also ok'
87+
})
88+
result.hydrate({ test: 'another text' })
89+
expect({ ...result }).toEqual({
90+
sku: '*43*',
91+
test: 'another text',
92+
test2: 'also ok'
93+
})
94+
})
9595

96-
it('It should also mutate the sub fields', () => {
97-
const result = ExampleMutator.create({
98-
noMutation: 'ok',
99-
sub: {
100-
first: 1,
101-
test: 42,
102-
last: 99,
103-
},
104-
});
105-
expect({ ...result }).toEqual({
106-
noMutation: 'ok',
107-
sub: {
108-
first: 1,
109-
test: '*42*',
110-
last: 99,
111-
},
112-
});
113-
});
96+
it('It should also mutate the sub fields', () => {
97+
const result = ExampleMutator.create({
98+
noMutation: 'ok',
99+
sub: {
100+
first: 1,
101+
test: 42,
102+
last: 99
103+
}
104+
})
105+
expect({ ...result }).toEqual({
106+
noMutation: 'ok',
107+
sub: {
108+
first: 1,
109+
test: '*42*',
110+
last: 99
111+
}
112+
})
113+
})
114114

115-
it('It should handle the product_group', () => {
116-
const result = ExampleMutator.create({
117-
product: { group: 'test' },
118-
another: { test: 'ok' },
119-
});
120-
expect({ ...result }).toEqual({
121-
product: { group: '*test*' },
122-
another: { test: 'ok' },
123-
});
124-
});
125-
});
115+
it('It should handle the product_group', () => {
116+
const result = ExampleMutator.create({
117+
product: { group: 'test' },
118+
another: { test: 'ok' }
119+
})
120+
expect({ ...result }).toEqual({
121+
product: { group: '*test*' },
122+
another: { test: 'ok' }
123+
})
124+
})
125+
})

src/__tests__/string-helper.unit.js

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
import { expect, describe, it } from '@jest/globals';
2-
import { capitalizeWords } from '../string-helper.js';
1+
import { expect, describe, it } from '@jest/globals'
2+
import { capitalizeWords } from '../string-helper.js'
33

44
const testCases = [
5-
{
6-
description: 'It should capitalize words',
7-
input: 'test',
8-
expectedResult: 'Test',
9-
},
10-
{
11-
description: 'It should capitalize "test_test_test"',
12-
input: 'test_test_test',
13-
expectedResult: 'TestTestTest',
14-
},
15-
{
16-
description: 'It should capitalize "test test test"',
17-
input: 'test test test',
18-
expectedResult: 'TestTestTest',
19-
},
20-
{
21-
description: 'It should capitalize "tEst teSt tesT"',
22-
input: 'tEst teSt tesT',
23-
expectedResult: 'TEstTeStTesT',
24-
},
25-
];
5+
{
6+
description: 'It should capitalize words',
7+
input: 'test',
8+
expectedResult: 'Test'
9+
},
10+
{
11+
description: 'It should capitalize "test_test_test"',
12+
input: 'test_test_test',
13+
expectedResult: 'TestTestTest'
14+
},
15+
{
16+
description: 'It should capitalize "test test test"',
17+
input: 'test test test',
18+
expectedResult: 'TestTestTest'
19+
},
20+
{
21+
description: 'It should capitalize "tEst teSt tesT"',
22+
input: 'tEst teSt tesT',
23+
expectedResult: 'TEstTeStTesT'
24+
}
25+
]
2626

2727
describe.each(testCases)(
28-
'Test the item filter method',
29-
({ description, input, expectedResult }) => {
30-
it(description, () => {
31-
const result = capitalizeWords(input);
32-
expect(result).toEqual(expectedResult);
33-
});
34-
}
35-
);
28+
'Test the item filter method',
29+
({ description, input, expectedResult }) => {
30+
it(description, () => {
31+
const result = capitalizeWords(input)
32+
expect(result).toEqual(expectedResult)
33+
})
34+
}
35+
)

0 commit comments

Comments
 (0)