Skip to content

Commit f2bdd14

Browse files
author
Valeriy Borodayev
committed
refactor:
1 parent f50fae6 commit f2bdd14

File tree

6 files changed

+3392
-2441
lines changed

6 files changed

+3392
-2441
lines changed

package.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,37 @@
2727
"homepage": "https://github.com/FrankAst/mongoose-history-diff",
2828
"license": "MIT",
2929
"dependencies": {
30-
"@babel/runtime": "^7.5.5"
30+
"@babel/runtime": "^7.8.4"
3131
},
3232
"peerDependencies": {
33-
"mongoose": "^5.6.10"
33+
"mongoose": "^5.8.11"
3434
},
3535
"devDependencies": {
36-
"@babel/cli": "^7.5.5",
37-
"@babel/core": "^7.5.5",
38-
"@babel/plugin-proposal-class-properties": "^7.5.5",
39-
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
40-
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
41-
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
42-
"@babel/plugin-transform-runtime": "^7.5.5",
43-
"@babel/preset-env": "^7.5.5",
44-
"@babel/preset-flow": "^7.0.0",
36+
"@babel/cli": "^7.8.4",
37+
"@babel/core": "^7.8.4",
38+
"@babel/plugin-proposal-class-properties": "^7.8.3",
39+
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
40+
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
41+
"@babel/plugin-transform-flow-strip-types": "^7.8.3",
42+
"@babel/plugin-transform-runtime": "^7.8.3",
43+
"@babel/preset-env": "^7.8.4",
44+
"@babel/preset-flow": "^7.8.3",
4545
"babel-core": "^7.0.0-bridge.0",
46-
"babel-eslint": "^10.0.2",
47-
"babel-jest": "^24.9.0",
46+
"babel-eslint": "^10.0.3",
47+
"babel-jest": "^25.1.0",
4848
"babel-preset-minify": "^0.5.1",
49-
"cz-conventional-changelog": "^3.0.2",
50-
"eslint": "^6.2.2",
49+
"cz-conventional-changelog": "^3.1.0",
50+
"eslint": "^6.8.0",
5151
"eslint-config-airbnb-base": "^14.0.0",
52-
"eslint-config-prettier": "^6.1.0",
53-
"eslint-plugin-flowtype": "^4.2.0",
54-
"eslint-plugin-import": "^2.18.2",
55-
"eslint-plugin-prettier": "^3.1.0",
56-
"flow-bin": "^0.106.1",
57-
"jest": "24.9.0",
58-
"mongodb-memory-server": "^5.2.0",
59-
"prettier": "^1.18.2",
60-
"semantic-release": "^15.13.24"
52+
"eslint-config-prettier": "^6.10.0",
53+
"eslint-plugin-flowtype": "^4.6.0",
54+
"eslint-plugin-import": "^2.20.1",
55+
"eslint-plugin-prettier": "^3.1.2",
56+
"flow-bin": "^0.117.0",
57+
"jest": "25.1.0",
58+
"mongodb-memory-server": "^6.2.4",
59+
"prettier": "^1.19.1",
60+
"semantic-release": "^17.0.2"
6161
},
6262
"publishConfig": {
6363
"access": "public"

src/__tests__/__snapshots__/plugin-test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`mongoose-dp save diffs 1`] = `
4-
CoreMongooseArray [
4+
CoreDocumentArray [
55
Object {
66
"k": "E",
77
"l": "test",

src/__tests__/diffModel-test.js

Lines changed: 98 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,46 @@ describe('Diff', () => {
3939
expect(diff2.v).toBe(2);
4040

4141
expect(diff1.c).toMatchInlineSnapshot(`
42-
CoreMongooseArray [
43-
Object {
44-
"k": "E",
45-
"l": "elements",
46-
"p": Array [
47-
"details",
48-
"with",
49-
"2",
50-
],
51-
"r": "more",
52-
},
53-
Object {
54-
"i": 3,
55-
"it": Object {
56-
"k": "N",
57-
"r": "elements",
58-
},
59-
"k": "A",
60-
"p": Array [
61-
"details",
62-
"with",
63-
],
64-
},
65-
]
66-
`);
42+
CoreDocumentArray [
43+
Object {
44+
"k": "E",
45+
"l": "elements",
46+
"p": Array [
47+
"details",
48+
"with",
49+
"2",
50+
],
51+
"r": "more",
52+
},
53+
Object {
54+
"i": 3,
55+
"it": Object {
56+
"k": "N",
57+
"r": "elements",
58+
},
59+
"k": "A",
60+
"p": Array [
61+
"details",
62+
"with",
63+
],
64+
},
65+
]
66+
`);
6767

6868
expect(diff2.c).toMatchInlineSnapshot(`
69-
CoreMongooseArray [
70-
Object {
71-
"k": "E",
72-
"l": "elements",
73-
"p": Array [
74-
"details",
75-
"with",
76-
"2",
77-
],
78-
"r": "more",
79-
},
80-
]
81-
`);
69+
CoreDocumentArray [
70+
Object {
71+
"k": "E",
72+
"l": "elements",
73+
"p": Array [
74+
"details",
75+
"with",
76+
"2",
77+
],
78+
"r": "more",
79+
},
80+
]
81+
`);
8282
});
8383

8484
it('findAfterVersion()', async () => {
@@ -96,60 +96,60 @@ CoreMongooseArray [
9696
const tillV1 = await Diff.findAfterVersion(docId, 1);
9797
const tillV2 = await Diff.findAfterVersion(docId, 2);
9898
expect(tillV1[0].c).toMatchInlineSnapshot(`
99-
CoreMongooseArray [
100-
Object {
101-
"k": "E",
102-
"l": "elements",
103-
"p": Array [
104-
"details",
105-
"with",
106-
"2",
107-
],
108-
"r": "more",
109-
},
110-
]
111-
`);
99+
CoreDocumentArray [
100+
Object {
101+
"k": "E",
102+
"l": "elements",
103+
"p": Array [
104+
"details",
105+
"with",
106+
"2",
107+
],
108+
"r": "more",
109+
},
110+
]
111+
`);
112112
expect(tillV1[1].c).toMatchInlineSnapshot(`
113-
CoreMongooseArray [
114-
Object {
115-
"k": "E",
116-
"l": "elements",
117-
"p": Array [
118-
"details",
119-
"with",
120-
"2",
121-
],
122-
"r": "more",
123-
},
124-
Object {
125-
"i": 3,
126-
"it": Object {
127-
"k": "N",
128-
"r": "elements",
129-
},
130-
"k": "A",
131-
"p": Array [
132-
"details",
133-
"with",
134-
],
135-
},
136-
]
137-
`);
113+
CoreDocumentArray [
114+
Object {
115+
"k": "E",
116+
"l": "elements",
117+
"p": Array [
118+
"details",
119+
"with",
120+
"2",
121+
],
122+
"r": "more",
123+
},
124+
Object {
125+
"i": 3,
126+
"it": Object {
127+
"k": "N",
128+
"r": "elements",
129+
},
130+
"k": "A",
131+
"p": Array [
132+
"details",
133+
"with",
134+
],
135+
},
136+
]
137+
`);
138138

139139
expect(tillV2[0].c).toMatchInlineSnapshot(`
140-
CoreMongooseArray [
141-
Object {
142-
"k": "E",
143-
"l": "elements",
144-
"p": Array [
145-
"details",
146-
"with",
147-
"2",
148-
],
149-
"r": "more",
150-
},
151-
]
152-
`);
140+
CoreDocumentArray [
141+
Object {
142+
"k": "E",
143+
"l": "elements",
144+
"p": Array [
145+
"details",
146+
"with",
147+
"2",
148+
],
149+
"r": "more",
150+
},
151+
]
152+
`);
153153
});
154154

155155
it('revertToVersion()', async () => {
@@ -171,15 +171,15 @@ CoreMongooseArray [
171171

172172
expect(post2.title).toBe('updated2');
173173
expect(post2.subjects).toMatchInlineSnapshot(`
174-
CoreMongooseArray [
175-
Object {
176-
"name": "math2",
177-
},
178-
Object {
179-
"name": "air2",
180-
},
181-
]
182-
`);
174+
CoreDocumentArray [
175+
Object {
176+
"name": "math2",
177+
},
178+
Object {
179+
"name": "air2",
180+
},
181+
]
182+
`);
183183
expect(revertedDoc.title).toBe('test');
184184
expect(revertedDoc.subjects).toMatchInlineSnapshot(`
185185
Array [

src/__tests__/plugin-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('mongoose-dp', () => {
4949
const Diff = Post.diffModel();
5050
const diffs = await Diff.findByDocId(post._id);
5151
expect(diffs[0].c).toMatchInlineSnapshot(`
52-
CoreMongooseArray [
52+
CoreDocumentArray [
5353
Object {
5454
"i": 1,
5555
"it": Object {
@@ -81,7 +81,7 @@ describe('mongoose-dp', () => {
8181
const Diff = Post.diffModel();
8282
const diffs = await Diff.findByDocId(post._id);
8383
expect(diffs[0].c).toMatchInlineSnapshot(`
84-
CoreMongooseArray [
84+
CoreDocumentArray [
8585
Object {
8686
"k": "E",
8787
"l": "was",
@@ -110,7 +110,7 @@ describe('mongoose-dp', () => {
110110
const Diff = Post.diffModel();
111111
const diffs = await Diff.findByDocId(post._id);
112112
expect(diffs[0].c).toMatchInlineSnapshot(`
113-
CoreMongooseArray [
113+
CoreDocumentArray [
114114
Object {
115115
"i": 2,
116116
"it": Object {

src/__tests__/utils-test.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,26 @@ describe('utils', () => {
168168
const revertedNew = revertArrayChange([1, 2, 3, 4], 3, { k: 'N', r: 4 });
169169
const revertedDeleted = revertArrayChange([1, 2, 3], 3, { k: 'D', l: 4 });
170170
const revertedEdited = revertArrayChange([1, 2, 3, 6], 3, { k: 'E', l: 5, r: 6 });
171-
const revertedArray = revertArrayChange([[1, 2], [1, 3]], 1, {
172-
k: 'A',
173-
i: 1,
174-
it: { k: 'E', l: 2, r: 3 },
175-
});
171+
const revertedArray = revertArrayChange(
172+
[
173+
[1, 2],
174+
[1, 3],
175+
],
176+
1,
177+
{
178+
k: 'A',
179+
i: 1,
180+
it: { k: 'E', l: 2, r: 3 },
181+
}
182+
);
176183

177184
expect(revertedNew).toEqual([1, 2, 3]);
178185
expect(revertedDeleted).toEqual([1, 2, 3, 4]);
179186
expect(revertedEdited).toEqual([1, 2, 3, 5]);
180-
expect(revertedArray).toEqual([[1, 2], [1, 2]]);
187+
expect(revertedArray).toEqual([
188+
[1, 2],
189+
[1, 2],
190+
]);
181191
});
182192

183193
it('deepClone()', () => {

0 commit comments

Comments
 (0)