Skip to content

Commit 84970b0

Browse files
authored
Merge pull request #3 from FrankAst/fix-ci
refactor: fix tests, ci
2 parents 61cf2b0 + 85f83fb commit 84970b0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/__tests__/diff-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('findDiff', () => {
3131
{ k: 'N', p: ['string'], r: 'str1' },
3232
{ k: 'N', p: ['newString'], r: 'str2' },
3333
{ k: 'N', p: ['number'], r: 1 },
34-
{ k: 'N', p: ['date'], r: new Date('2018-11-29T18:00:00.000Z') },
34+
{ k: 'N', p: ['date'], r: new Date('2018/11/30') },
3535
]);
3636

3737
expect(modifiedDiffs).toEqual([
@@ -43,9 +43,9 @@ describe('findDiff', () => {
4343
{ k: 'E', l: 0, p: ['number'], r: 1 },
4444
{
4545
k: 'E',
46-
l: new Date('2018-12-29T18:00:00.000Z'),
46+
l: new Date('2018/12/30'),
4747
p: ['date'],
48-
r: new Date('2018-11-29T18:00:00.000Z'),
48+
r: new Date('2018/11/30'),
4949
},
5050
{ k: 'N', p: ['newString'], r: 'str2' },
5151
]);

src/definitions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ export class DiffDoc /* :: extends Mongoose$Document */ {
6565
.exec();
6666
}
6767

68-
static async revertToVersion(doc: Object, v: number): Promise<any> {
68+
static async revertToVersion(d: Object, v: number): Promise<any> {
69+
const doc = typeof d.toObject === 'function' ? d.toObject() : d;
6970
const changes: Array<RawChangeT> = [];
7071
const diffDocs = (await this.findAfterVersion(doc._id, v): any);
7172

7273
if (diffDocs.length === 0) return null;
73-
diffDocs.forEach(d => changes.push(...d.c));
74+
diffDocs.forEach(diffDoc => changes.push(...diffDoc.c));
7475
return revertChanges(doc, changes);
7576
}
7677

0 commit comments

Comments
 (0)