@opentermsarchive/engine 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/scripts/declarations/lint/index.mocha.js +3 -3
- package/scripts/declarations/validate/index.mocha.js +5 -5
- package/scripts/history/migrate-services.js +1 -1
- package/scripts/import/index.js +1 -1
- package/src/api/routes/docs.test.js +2 -2
- package/src/api/routes/versions.test.js +1 -1
- package/src/archivist/fetcher/fullDomFetcher.js +5 -5
- package/src/archivist/fetcher/index.test.js +5 -5
- package/src/archivist/index.test.js +16 -16
- package/src/archivist/recorder/index.js +4 -4
- package/src/archivist/recorder/index.test.js +29 -29
- package/src/archivist/recorder/repositories/git/git.js +6 -6
- package/src/archivist/recorder/repositories/git/index.js +4 -2
- package/src/archivist/recorder/repositories/git/index.test.js +65 -44
- package/src/archivist/recorder/repositories/interface.js +3 -0
- package/src/archivist/recorder/repositories/mongo/index.js +3 -3
- package/src/archivist/recorder/repositories/mongo/index.test.js +36 -36
- package/src/archivist/recorder/snapshot.test.js +4 -4
- package/src/archivist/recorder/version.test.js +4 -4
- package/src/archivist/services/index.test.js +16 -16
- package/src/archivist/services/sourceDocument.test.js +11 -11
- package/src/archivist/services/terms.test.js +2 -2
- package/src/notifier/index.js +2 -2
|
@@ -91,7 +91,7 @@ describe('GitRepository', () => {
|
|
|
91
91
|
([commit] = await git.log());
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
after(
|
|
94
|
+
after(() => subject.removeAll());
|
|
95
95
|
|
|
96
96
|
it('saves the record', () => {
|
|
97
97
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -158,7 +158,7 @@ describe('GitRepository', () => {
|
|
|
158
158
|
([commit] = await git.log());
|
|
159
159
|
});
|
|
160
160
|
|
|
161
|
-
after(
|
|
161
|
+
after(() => subject.removeAll());
|
|
162
162
|
|
|
163
163
|
it('saves the record', () => {
|
|
164
164
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -194,7 +194,7 @@ describe('GitRepository', () => {
|
|
|
194
194
|
numberOfRecordsAfter = (await git.log()).length;
|
|
195
195
|
});
|
|
196
196
|
|
|
197
|
-
after(
|
|
197
|
+
after(() => subject.removeAll());
|
|
198
198
|
|
|
199
199
|
it('does not save the record', () => {
|
|
200
200
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore);
|
|
@@ -232,7 +232,7 @@ describe('GitRepository', () => {
|
|
|
232
232
|
([commit] = await git.log());
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
-
after(
|
|
235
|
+
after(() => subject.removeAll());
|
|
236
236
|
|
|
237
237
|
it('saves the record', () => {
|
|
238
238
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -263,7 +263,7 @@ describe('GitRepository', () => {
|
|
|
263
263
|
([commit] = await git.log());
|
|
264
264
|
});
|
|
265
265
|
|
|
266
|
-
after(
|
|
266
|
+
after(() => subject.removeAll());
|
|
267
267
|
|
|
268
268
|
it('stores snapshot ID', () => {
|
|
269
269
|
expect(commit.body).to.include(config.get('recorder.versions.storage.git.snapshotIdentiferTemplate').replace(SNAPSHOT_ID_MARKER, SNAPSHOT_ID));
|
|
@@ -295,7 +295,7 @@ describe('GitRepository', () => {
|
|
|
295
295
|
([commit] = await git.log());
|
|
296
296
|
});
|
|
297
297
|
|
|
298
|
-
after(
|
|
298
|
+
after(() => subject.removeAll());
|
|
299
299
|
|
|
300
300
|
it('stores snapshots IDs', () => {
|
|
301
301
|
expect(commit.body).to.include(config.get('recorder.versions.storage.git.snapshotIdentiferTemplate').replace(SNAPSHOT_ID_MARKER, SNAPSHOT_ID_1));
|
|
@@ -333,7 +333,7 @@ describe('GitRepository', () => {
|
|
|
333
333
|
(record = await subject.findById(id));
|
|
334
334
|
});
|
|
335
335
|
|
|
336
|
-
after(
|
|
336
|
+
after(() => subject.removeAll());
|
|
337
337
|
|
|
338
338
|
it('returns a Version object', () => {
|
|
339
339
|
expect(record).to.be.an.instanceof(Version);
|
|
@@ -355,7 +355,7 @@ describe('GitRepository', () => {
|
|
|
355
355
|
expect(record.termsType).to.equal(TERMS_TYPE);
|
|
356
356
|
});
|
|
357
357
|
|
|
358
|
-
it('returns the content',
|
|
358
|
+
it('returns the content', () => {
|
|
359
359
|
expect(record.content).to.equal(CONTENT);
|
|
360
360
|
});
|
|
361
361
|
|
|
@@ -412,7 +412,7 @@ describe('GitRepository', () => {
|
|
|
412
412
|
recordFound = await subject.findByDate(SERVICE_PROVIDER_ID, TERMS_TYPE, oneHourBeforeFetchDateLater);
|
|
413
413
|
});
|
|
414
414
|
|
|
415
|
-
after(
|
|
415
|
+
after(() => subject.removeAll());
|
|
416
416
|
|
|
417
417
|
it('returns a Version object', () => {
|
|
418
418
|
expect(recordFound).to.be.an.instanceof(Version);
|
|
@@ -431,7 +431,7 @@ describe('GitRepository', () => {
|
|
|
431
431
|
recordFound = await subject.findByDate(SERVICE_PROVIDER_ID, TERMS_TYPE);
|
|
432
432
|
});
|
|
433
433
|
|
|
434
|
-
it('returns null',
|
|
434
|
+
it('returns null', () => {
|
|
435
435
|
expect(recordFound).to.equal(null);
|
|
436
436
|
});
|
|
437
437
|
});
|
|
@@ -478,7 +478,7 @@ describe('GitRepository', () => {
|
|
|
478
478
|
(records = await subject.findAll());
|
|
479
479
|
});
|
|
480
480
|
|
|
481
|
-
after(
|
|
481
|
+
after(() => subject.removeAll());
|
|
482
482
|
|
|
483
483
|
it('returns all records', () => {
|
|
484
484
|
expect(records.length).to.equal(3);
|
|
@@ -490,7 +490,7 @@ describe('GitRepository', () => {
|
|
|
490
490
|
}
|
|
491
491
|
});
|
|
492
492
|
|
|
493
|
-
it('returns records in ascending order',
|
|
493
|
+
it('returns records in ascending order', () => {
|
|
494
494
|
expect(records.map(record => record.fetchDate)).to.deep.equal([ FETCH_DATE_EARLIER, FETCH_DATE, FETCH_DATE_LATER ]);
|
|
495
495
|
});
|
|
496
496
|
});
|
|
@@ -527,9 +527,9 @@ describe('GitRepository', () => {
|
|
|
527
527
|
(count = await subject.count());
|
|
528
528
|
});
|
|
529
529
|
|
|
530
|
-
after(
|
|
530
|
+
after(() => subject.removeAll());
|
|
531
531
|
|
|
532
|
-
it('returns the proper count',
|
|
532
|
+
it('returns the proper count', () => {
|
|
533
533
|
expect(count).to.equal(3);
|
|
534
534
|
});
|
|
535
535
|
});
|
|
@@ -562,7 +562,7 @@ describe('GitRepository', () => {
|
|
|
562
562
|
latestRecord = await subject.findLatest(SERVICE_PROVIDER_ID, TERMS_TYPE);
|
|
563
563
|
});
|
|
564
564
|
|
|
565
|
-
after(
|
|
565
|
+
after(() => subject.removeAll());
|
|
566
566
|
|
|
567
567
|
it('returns a Version object', () => {
|
|
568
568
|
expect(latestRecord).to.be.an.instanceof(Version);
|
|
@@ -572,7 +572,7 @@ describe('GitRepository', () => {
|
|
|
572
572
|
expect(latestRecord.id).to.include(lastSnapshotId);
|
|
573
573
|
});
|
|
574
574
|
|
|
575
|
-
it('returns the latest record content',
|
|
575
|
+
it('returns the latest record content', () => {
|
|
576
576
|
expect(latestRecord.content.toString('utf8')).to.equal(UPDATED_FILE_CONTENT);
|
|
577
577
|
});
|
|
578
578
|
});
|
|
@@ -585,7 +585,7 @@ describe('GitRepository', () => {
|
|
|
585
585
|
latestRecord = await subject.findLatest(SERVICE_PROVIDER_ID, TERMS_TYPE);
|
|
586
586
|
});
|
|
587
587
|
|
|
588
|
-
it('returns null',
|
|
588
|
+
it('returns null', () => {
|
|
589
589
|
expect(latestRecord).to.equal(null);
|
|
590
590
|
});
|
|
591
591
|
});
|
|
@@ -637,15 +637,36 @@ describe('GitRepository', () => {
|
|
|
637
637
|
}
|
|
638
638
|
});
|
|
639
639
|
|
|
640
|
-
after(
|
|
640
|
+
after(() => subject.removeAll());
|
|
641
641
|
|
|
642
|
-
it('iterates through all records',
|
|
642
|
+
it('iterates through all records', () => {
|
|
643
643
|
expect(ids).to.have.members(expectedIds);
|
|
644
644
|
});
|
|
645
645
|
|
|
646
|
-
it('iterates in ascending order',
|
|
646
|
+
it('iterates in ascending order', () => {
|
|
647
647
|
expect(fetchDates).to.deep.equal([ FETCH_DATE_EARLIER, FETCH_DATE, FETCH_DATE_LATER ]);
|
|
648
648
|
});
|
|
649
|
+
|
|
650
|
+
context('when the repository contains non-record commits (e.g., README or LICENSE updates)', () => {
|
|
651
|
+
const iteratedIds = [];
|
|
652
|
+
let extraCommitId;
|
|
653
|
+
|
|
654
|
+
before(async () => {
|
|
655
|
+
await fs.writeFileSync(path.resolve(subject.path, 'README.md'), '# README');
|
|
656
|
+
await subject.git.add(path.resolve(subject.path, 'README.md'));
|
|
657
|
+
extraCommitId = await subject.git.commit({ message: 'Update README', filePath: path.resolve(subject.path, 'README.md') });
|
|
658
|
+
|
|
659
|
+
for await (const record of subject.iterate()) {
|
|
660
|
+
iteratedIds.push(record.id);
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
after(() => subject.removeAll());
|
|
665
|
+
|
|
666
|
+
it('iterates through records only', () => {
|
|
667
|
+
expect(iteratedIds).to.not.contains(extraCommitId);
|
|
668
|
+
});
|
|
669
|
+
});
|
|
649
670
|
});
|
|
650
671
|
});
|
|
651
672
|
|
|
@@ -695,7 +716,7 @@ describe('GitRepository', () => {
|
|
|
695
716
|
([commit] = await git.log());
|
|
696
717
|
});
|
|
697
718
|
|
|
698
|
-
after(
|
|
719
|
+
after(() => subject.removeAll());
|
|
699
720
|
|
|
700
721
|
it('saves the record', () => {
|
|
701
722
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -765,7 +786,7 @@ describe('GitRepository', () => {
|
|
|
765
786
|
([commit] = await git.log());
|
|
766
787
|
});
|
|
767
788
|
|
|
768
|
-
after(
|
|
789
|
+
after(() => subject.removeAll());
|
|
769
790
|
|
|
770
791
|
it('saves the record', () => {
|
|
771
792
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -803,7 +824,7 @@ describe('GitRepository', () => {
|
|
|
803
824
|
numberOfRecordsAfter = (await git.log()).length;
|
|
804
825
|
});
|
|
805
826
|
|
|
806
|
-
after(
|
|
827
|
+
after(() => subject.removeAll());
|
|
807
828
|
|
|
808
829
|
it('does not save the record', () => {
|
|
809
830
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore);
|
|
@@ -831,7 +852,7 @@ describe('GitRepository', () => {
|
|
|
831
852
|
([commit] = await git.log());
|
|
832
853
|
});
|
|
833
854
|
|
|
834
|
-
after(
|
|
855
|
+
after(() => subject.removeAll());
|
|
835
856
|
|
|
836
857
|
it('saves the record', () => {
|
|
837
858
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -863,7 +884,7 @@ describe('GitRepository', () => {
|
|
|
863
884
|
([commit] = await git.log());
|
|
864
885
|
});
|
|
865
886
|
|
|
866
|
-
after(
|
|
887
|
+
after(() => subject.removeAll());
|
|
867
888
|
|
|
868
889
|
it('saves the record', () => {
|
|
869
890
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -899,7 +920,7 @@ describe('GitRepository', () => {
|
|
|
899
920
|
(record = await subject.findById(id));
|
|
900
921
|
});
|
|
901
922
|
|
|
902
|
-
after(
|
|
923
|
+
after(() => subject.removeAll());
|
|
903
924
|
|
|
904
925
|
it('returns a Snapshot object', () => {
|
|
905
926
|
expect(record).to.be.an.instanceof(Snapshot);
|
|
@@ -921,7 +942,7 @@ describe('GitRepository', () => {
|
|
|
921
942
|
expect(record.termsType).to.equal(TERMS_TYPE);
|
|
922
943
|
});
|
|
923
944
|
|
|
924
|
-
it('returns the content',
|
|
945
|
+
it('returns the content', () => {
|
|
925
946
|
expect(record.content).to.equal(CONTENT);
|
|
926
947
|
});
|
|
927
948
|
|
|
@@ -986,7 +1007,7 @@ describe('GitRepository', () => {
|
|
|
986
1007
|
(records = await subject.findAll());
|
|
987
1008
|
});
|
|
988
1009
|
|
|
989
|
-
after(
|
|
1010
|
+
after(() => subject.removeAll());
|
|
990
1011
|
|
|
991
1012
|
it('returns all records', () => {
|
|
992
1013
|
expect(records.length).to.equal(3);
|
|
@@ -998,7 +1019,7 @@ describe('GitRepository', () => {
|
|
|
998
1019
|
}
|
|
999
1020
|
});
|
|
1000
1021
|
|
|
1001
|
-
it('returns records in ascending order',
|
|
1022
|
+
it('returns records in ascending order', () => {
|
|
1002
1023
|
expect(records.map(record => record.fetchDate)).to.deep.equal([ FETCH_DATE_EARLIER, FETCH_DATE, FETCH_DATE_LATER ]);
|
|
1003
1024
|
});
|
|
1004
1025
|
});
|
|
@@ -1035,9 +1056,9 @@ describe('GitRepository', () => {
|
|
|
1035
1056
|
(count = await subject.count());
|
|
1036
1057
|
});
|
|
1037
1058
|
|
|
1038
|
-
after(
|
|
1059
|
+
after(() => subject.removeAll());
|
|
1039
1060
|
|
|
1040
|
-
it('returns the proper count',
|
|
1061
|
+
it('returns the proper count', () => {
|
|
1041
1062
|
expect(count).to.equal(3);
|
|
1042
1063
|
});
|
|
1043
1064
|
});
|
|
@@ -1070,7 +1091,7 @@ describe('GitRepository', () => {
|
|
|
1070
1091
|
latestRecord = await subject.findLatest(SERVICE_PROVIDER_ID, TERMS_TYPE);
|
|
1071
1092
|
});
|
|
1072
1093
|
|
|
1073
|
-
after(
|
|
1094
|
+
after(() => subject.removeAll());
|
|
1074
1095
|
|
|
1075
1096
|
it('returns a Snapshot object', () => {
|
|
1076
1097
|
expect(latestRecord).to.be.an.instanceof(Snapshot);
|
|
@@ -1080,7 +1101,7 @@ describe('GitRepository', () => {
|
|
|
1080
1101
|
expect(latestRecord.id).to.include(lastSnapshotId);
|
|
1081
1102
|
});
|
|
1082
1103
|
|
|
1083
|
-
it('returns the latest record content',
|
|
1104
|
+
it('returns the latest record content', () => {
|
|
1084
1105
|
expect(latestRecord.content.toString('utf8')).to.equal(UPDATED_FILE_CONTENT);
|
|
1085
1106
|
});
|
|
1086
1107
|
|
|
@@ -1102,13 +1123,13 @@ describe('GitRepository', () => {
|
|
|
1102
1123
|
latestRecord = await subject.findLatest(SERVICE_PROVIDER_ID, TERMS_TYPE);
|
|
1103
1124
|
});
|
|
1104
1125
|
|
|
1105
|
-
after(
|
|
1126
|
+
after(() => subject.removeAll());
|
|
1106
1127
|
|
|
1107
1128
|
it('returns the latest record id', () => {
|
|
1108
1129
|
expect(latestRecord.id).to.include(lastSnapshotId);
|
|
1109
1130
|
});
|
|
1110
1131
|
|
|
1111
|
-
it('returns the latest record content',
|
|
1132
|
+
it('returns the latest record content', () => {
|
|
1112
1133
|
expect(latestRecord.content.toString('utf8')).to.equal(PDF_CONTENT);
|
|
1113
1134
|
});
|
|
1114
1135
|
|
|
@@ -1125,7 +1146,7 @@ describe('GitRepository', () => {
|
|
|
1125
1146
|
latestRecord = await subject.findLatest(SERVICE_PROVIDER_ID, TERMS_TYPE);
|
|
1126
1147
|
});
|
|
1127
1148
|
|
|
1128
|
-
it('returns null',
|
|
1149
|
+
it('returns null', () => {
|
|
1129
1150
|
expect(latestRecord).to.equal(null);
|
|
1130
1151
|
});
|
|
1131
1152
|
});
|
|
@@ -1174,13 +1195,13 @@ describe('GitRepository', () => {
|
|
|
1174
1195
|
}
|
|
1175
1196
|
});
|
|
1176
1197
|
|
|
1177
|
-
after(
|
|
1198
|
+
after(() => subject.removeAll());
|
|
1178
1199
|
|
|
1179
|
-
it('iterates through all records',
|
|
1200
|
+
it('iterates through all records', () => {
|
|
1180
1201
|
expect(ids).to.have.members(expectedIds);
|
|
1181
1202
|
});
|
|
1182
1203
|
|
|
1183
|
-
it('iterates in ascending order',
|
|
1204
|
+
it('iterates in ascending order', () => {
|
|
1184
1205
|
expect(fetchDates).to.deep.equal([ FETCH_DATE_EARLIER, FETCH_DATE, FETCH_DATE_LATER ]);
|
|
1185
1206
|
});
|
|
1186
1207
|
});
|
|
@@ -1266,7 +1287,7 @@ describe('GitRepository', () => {
|
|
|
1266
1287
|
/* eslint-enable no-await-in-loop */
|
|
1267
1288
|
});
|
|
1268
1289
|
|
|
1269
|
-
after(
|
|
1290
|
+
after(() => subject.removeAll());
|
|
1270
1291
|
|
|
1271
1292
|
describe('Records attributes', () => {
|
|
1272
1293
|
describe('#isExtractOnly', () => {
|
|
@@ -1333,7 +1354,7 @@ describe('GitRepository', () => {
|
|
|
1333
1354
|
}
|
|
1334
1355
|
});
|
|
1335
1356
|
|
|
1336
|
-
it('returns records in ascending order',
|
|
1357
|
+
it('returns records in ascending order', () => {
|
|
1337
1358
|
expect(records.map(record => record.fetchDate)).to.deep.equal(expectedDates);
|
|
1338
1359
|
});
|
|
1339
1360
|
});
|
|
@@ -1345,7 +1366,7 @@ describe('GitRepository', () => {
|
|
|
1345
1366
|
(count = await subject.count());
|
|
1346
1367
|
});
|
|
1347
1368
|
|
|
1348
|
-
it('returns the proper count',
|
|
1369
|
+
it('returns the proper count', () => {
|
|
1349
1370
|
expect(count).to.equal(expectedIds.length);
|
|
1350
1371
|
});
|
|
1351
1372
|
});
|
|
@@ -1361,11 +1382,11 @@ describe('GitRepository', () => {
|
|
|
1361
1382
|
}
|
|
1362
1383
|
});
|
|
1363
1384
|
|
|
1364
|
-
it('iterates through all records',
|
|
1385
|
+
it('iterates through all records', () => {
|
|
1365
1386
|
expect(ids).to.have.members(expectedIds);
|
|
1366
1387
|
});
|
|
1367
1388
|
|
|
1368
|
-
it('iterates in ascending order',
|
|
1389
|
+
it('iterates in ascending order', () => {
|
|
1369
1390
|
expect(fetchDates).to.deep.equal(expectedDates);
|
|
1370
1391
|
});
|
|
1371
1392
|
});
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* @see {@link https://martinfowler.com/eaaCatalog/repository.html|Repository}
|
|
4
4
|
* @interface
|
|
5
5
|
*/
|
|
6
|
+
|
|
7
|
+
/* eslint-disable require-await */
|
|
6
8
|
class RepositoryInterface {
|
|
7
9
|
/**
|
|
8
10
|
* [Optional] Initialize repository
|
|
@@ -122,3 +124,4 @@ class RepositoryInterface {
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
export default RepositoryInterface;
|
|
127
|
+
/* eslint-enable require-await */
|
|
@@ -29,7 +29,7 @@ export default class MongoRepository extends RepositoryInterface {
|
|
|
29
29
|
return this;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
finalize() {
|
|
33
33
|
return this.client.close();
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -77,7 +77,7 @@ export default class MongoRepository extends RepositoryInterface {
|
|
|
77
77
|
.map(mongoDocument => this.#toDomain(mongoDocument, { deferContentLoading: true })));
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
count() {
|
|
81
81
|
return this.collection.find().count();
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -93,7 +93,7 @@ export default class MongoRepository extends RepositoryInterface {
|
|
|
93
93
|
/* eslint-enable no-await-in-loop */
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
removeAll() {
|
|
97
97
|
return this.collection.deleteMany();
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -81,7 +81,7 @@ describe('MongoRepository', () => {
|
|
|
81
81
|
}));
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
after(
|
|
84
|
+
after(() => subject.removeAll());
|
|
85
85
|
|
|
86
86
|
it('saves the record', () => {
|
|
87
87
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -156,7 +156,7 @@ describe('MongoRepository', () => {
|
|
|
156
156
|
}).limit(1).sort({ created_at: -1 }).toArray());
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
-
after(
|
|
159
|
+
after(() => subject.removeAll());
|
|
160
160
|
|
|
161
161
|
it('saves the record', () => {
|
|
162
162
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -200,7 +200,7 @@ describe('MongoRepository', () => {
|
|
|
200
200
|
}).count();
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
-
after(
|
|
203
|
+
after(() => subject.removeAll());
|
|
204
204
|
|
|
205
205
|
it('does not save the record', () => {
|
|
206
206
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore);
|
|
@@ -248,7 +248,7 @@ describe('MongoRepository', () => {
|
|
|
248
248
|
}).limit(1).sort({ created_at: -1 }).toArray());
|
|
249
249
|
});
|
|
250
250
|
|
|
251
|
-
after(
|
|
251
|
+
after(() => subject.removeAll());
|
|
252
252
|
|
|
253
253
|
it('saves the record', () => {
|
|
254
254
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -279,7 +279,7 @@ describe('MongoRepository', () => {
|
|
|
279
279
|
}));
|
|
280
280
|
});
|
|
281
281
|
|
|
282
|
-
after(
|
|
282
|
+
after(() => subject.removeAll());
|
|
283
283
|
|
|
284
284
|
it('stores snapshot ID', () => {
|
|
285
285
|
const snapshotIds = mongoDocument.snapshotIds.map(id => id.toString());
|
|
@@ -315,7 +315,7 @@ describe('MongoRepository', () => {
|
|
|
315
315
|
}));
|
|
316
316
|
});
|
|
317
317
|
|
|
318
|
-
after(
|
|
318
|
+
after(() => subject.removeAll());
|
|
319
319
|
|
|
320
320
|
it('stores snapshots IDs', () => {
|
|
321
321
|
const snapshotIds = mongoDocument.snapshotIds.map(id => id.toString());
|
|
@@ -350,7 +350,7 @@ describe('MongoRepository', () => {
|
|
|
350
350
|
(record = await subject.findById(id));
|
|
351
351
|
});
|
|
352
352
|
|
|
353
|
-
after(
|
|
353
|
+
after(() => subject.removeAll());
|
|
354
354
|
|
|
355
355
|
it('returns a Version object', () => {
|
|
356
356
|
expect(record).to.be.an.instanceof(Version);
|
|
@@ -372,7 +372,7 @@ describe('MongoRepository', () => {
|
|
|
372
372
|
expect(record.termsType).to.equal(TERMS_TYPE);
|
|
373
373
|
});
|
|
374
374
|
|
|
375
|
-
it('returns the content',
|
|
375
|
+
it('returns the content', () => {
|
|
376
376
|
expect(record.content).to.equal(CONTENT);
|
|
377
377
|
});
|
|
378
378
|
|
|
@@ -429,7 +429,7 @@ describe('MongoRepository', () => {
|
|
|
429
429
|
recordFound = await subject.findByDate(SERVICE_PROVIDER_ID, TERMS_TYPE, oneHourBeforeFetchDateLater);
|
|
430
430
|
});
|
|
431
431
|
|
|
432
|
-
after(
|
|
432
|
+
after(() => subject.removeAll());
|
|
433
433
|
|
|
434
434
|
it('returns a Version object', () => {
|
|
435
435
|
expect(recordFound).to.be.an.instanceof(Version);
|
|
@@ -481,7 +481,7 @@ describe('MongoRepository', () => {
|
|
|
481
481
|
(records = await subject.findAll());
|
|
482
482
|
});
|
|
483
483
|
|
|
484
|
-
after(
|
|
484
|
+
after(() => subject.removeAll());
|
|
485
485
|
|
|
486
486
|
it('returns all records', () => {
|
|
487
487
|
expect(records.length).to.equal(3);
|
|
@@ -493,7 +493,7 @@ describe('MongoRepository', () => {
|
|
|
493
493
|
}
|
|
494
494
|
});
|
|
495
495
|
|
|
496
|
-
it('returns records in ascending order',
|
|
496
|
+
it('returns records in ascending order', () => {
|
|
497
497
|
expect(records.map(record => record.fetchDate)).to.deep.equal([ FETCH_DATE_EARLIER, FETCH_DATE, FETCH_DATE_LATER ]);
|
|
498
498
|
});
|
|
499
499
|
});
|
|
@@ -528,9 +528,9 @@ describe('MongoRepository', () => {
|
|
|
528
528
|
(count = await subject.count());
|
|
529
529
|
});
|
|
530
530
|
|
|
531
|
-
after(
|
|
531
|
+
after(() => subject.removeAll());
|
|
532
532
|
|
|
533
|
-
it('returns the proper count',
|
|
533
|
+
it('returns the proper count', () => {
|
|
534
534
|
expect(count).to.equal(3);
|
|
535
535
|
});
|
|
536
536
|
});
|
|
@@ -566,7 +566,7 @@ describe('MongoRepository', () => {
|
|
|
566
566
|
);
|
|
567
567
|
});
|
|
568
568
|
|
|
569
|
-
after(
|
|
569
|
+
after(() => subject.removeAll());
|
|
570
570
|
|
|
571
571
|
it('returns a Version object', () => {
|
|
572
572
|
expect(latestRecord).to.be.an.instanceof(Version);
|
|
@@ -589,7 +589,7 @@ describe('MongoRepository', () => {
|
|
|
589
589
|
latestRecord = await subject.findLatest(SERVICE_PROVIDER_ID, TERMS_TYPE);
|
|
590
590
|
});
|
|
591
591
|
|
|
592
|
-
it('returns null',
|
|
592
|
+
it('returns null', () => {
|
|
593
593
|
expect(latestRecord).to.equal(null);
|
|
594
594
|
});
|
|
595
595
|
});
|
|
@@ -638,13 +638,13 @@ describe('MongoRepository', () => {
|
|
|
638
638
|
}
|
|
639
639
|
});
|
|
640
640
|
|
|
641
|
-
after(
|
|
641
|
+
after(() => subject.removeAll());
|
|
642
642
|
|
|
643
|
-
it('iterates through all records',
|
|
643
|
+
it('iterates through all records', () => {
|
|
644
644
|
expect(ids).to.have.members(expectedIds);
|
|
645
645
|
});
|
|
646
646
|
|
|
647
|
-
it('iterates in ascending order',
|
|
647
|
+
it('iterates in ascending order', () => {
|
|
648
648
|
expect(fetchDates).to.deep.equal([ FETCH_DATE_EARLIER, FETCH_DATE, FETCH_DATE_LATER ]);
|
|
649
649
|
});
|
|
650
650
|
});
|
|
@@ -693,7 +693,7 @@ describe('MongoRepository', () => {
|
|
|
693
693
|
}));
|
|
694
694
|
});
|
|
695
695
|
|
|
696
|
-
after(
|
|
696
|
+
after(() => subject.removeAll());
|
|
697
697
|
|
|
698
698
|
it('saves the record', () => {
|
|
699
699
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -772,7 +772,7 @@ describe('MongoRepository', () => {
|
|
|
772
772
|
}).limit(1).sort({ created_at: -1 }).toArray());
|
|
773
773
|
});
|
|
774
774
|
|
|
775
|
-
after(
|
|
775
|
+
after(() => subject.removeAll());
|
|
776
776
|
|
|
777
777
|
it('saves the record', () => {
|
|
778
778
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -816,7 +816,7 @@ describe('MongoRepository', () => {
|
|
|
816
816
|
}).count();
|
|
817
817
|
});
|
|
818
818
|
|
|
819
|
-
after(
|
|
819
|
+
after(() => subject.removeAll());
|
|
820
820
|
|
|
821
821
|
it('does not save the record', () => {
|
|
822
822
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore);
|
|
@@ -855,7 +855,7 @@ describe('MongoRepository', () => {
|
|
|
855
855
|
}));
|
|
856
856
|
});
|
|
857
857
|
|
|
858
|
-
after(
|
|
858
|
+
after(() => subject.removeAll());
|
|
859
859
|
|
|
860
860
|
it('saves the record', () => {
|
|
861
861
|
expect(numberOfRecordsAfter).to.equal(numberOfRecordsBefore + 1);
|
|
@@ -865,7 +865,7 @@ describe('MongoRepository', () => {
|
|
|
865
865
|
expect(mongoDocument._id.toString()).to.equal(record.id);
|
|
866
866
|
});
|
|
867
867
|
|
|
868
|
-
it('stores the proper content',
|
|
868
|
+
it('stores the proper content', () => {
|
|
869
869
|
const isSameContent = Buffer.compare(mongoDocument.content.buffer, PDF_CONTENT) == 0;
|
|
870
870
|
|
|
871
871
|
expect(isSameContent).to.be.true;
|
|
@@ -894,7 +894,7 @@ describe('MongoRepository', () => {
|
|
|
894
894
|
(record = await subject.findById(id));
|
|
895
895
|
});
|
|
896
896
|
|
|
897
|
-
after(
|
|
897
|
+
after(() => subject.removeAll());
|
|
898
898
|
|
|
899
899
|
it('returns a Snapshot object', () => {
|
|
900
900
|
expect(record).to.be.an.instanceof(Snapshot);
|
|
@@ -916,7 +916,7 @@ describe('MongoRepository', () => {
|
|
|
916
916
|
expect(record.termsType).to.equal(TERMS_TYPE);
|
|
917
917
|
});
|
|
918
918
|
|
|
919
|
-
it('returns the content',
|
|
919
|
+
it('returns the content', () => {
|
|
920
920
|
expect(record.content).to.equal(CONTENT);
|
|
921
921
|
});
|
|
922
922
|
|
|
@@ -978,7 +978,7 @@ describe('MongoRepository', () => {
|
|
|
978
978
|
(records = await subject.findAll());
|
|
979
979
|
});
|
|
980
980
|
|
|
981
|
-
after(
|
|
981
|
+
after(() => subject.removeAll());
|
|
982
982
|
|
|
983
983
|
it('returns all records', () => {
|
|
984
984
|
expect(records.length).to.equal(3);
|
|
@@ -990,7 +990,7 @@ describe('MongoRepository', () => {
|
|
|
990
990
|
}
|
|
991
991
|
});
|
|
992
992
|
|
|
993
|
-
it('returns records in ascending order',
|
|
993
|
+
it('returns records in ascending order', () => {
|
|
994
994
|
expect(records.map(record => record.fetchDate)).to.deep.equal([ FETCH_DATE_EARLIER, FETCH_DATE, FETCH_DATE_LATER ]);
|
|
995
995
|
});
|
|
996
996
|
});
|
|
@@ -1025,9 +1025,9 @@ describe('MongoRepository', () => {
|
|
|
1025
1025
|
(count = await subject.count());
|
|
1026
1026
|
});
|
|
1027
1027
|
|
|
1028
|
-
after(
|
|
1028
|
+
after(() => subject.removeAll());
|
|
1029
1029
|
|
|
1030
|
-
it('returns the proper count',
|
|
1030
|
+
it('returns the proper count', () => {
|
|
1031
1031
|
expect(count).to.equal(3);
|
|
1032
1032
|
});
|
|
1033
1033
|
});
|
|
@@ -1063,7 +1063,7 @@ describe('MongoRepository', () => {
|
|
|
1063
1063
|
);
|
|
1064
1064
|
});
|
|
1065
1065
|
|
|
1066
|
-
after(
|
|
1066
|
+
after(() => subject.removeAll());
|
|
1067
1067
|
|
|
1068
1068
|
it('returns a Snapshot object', () => {
|
|
1069
1069
|
expect(latestRecord).to.be.an.instanceof(Snapshot);
|
|
@@ -1103,13 +1103,13 @@ describe('MongoRepository', () => {
|
|
|
1103
1103
|
latestRecord = await subject.findLatest(SERVICE_PROVIDER_ID, TERMS_TYPE);
|
|
1104
1104
|
});
|
|
1105
1105
|
|
|
1106
|
-
after(
|
|
1106
|
+
after(() => subject.removeAll());
|
|
1107
1107
|
|
|
1108
1108
|
it('returns the latest record id', () => {
|
|
1109
1109
|
expect(latestRecord.id).to.include(lastSnapshotId);
|
|
1110
1110
|
});
|
|
1111
1111
|
|
|
1112
|
-
it('returns the latest record content',
|
|
1112
|
+
it('returns the latest record content', () => {
|
|
1113
1113
|
const isSameContent = Buffer.compare(latestRecord.content, UPDATED_PDF_CONTENT) == 0;
|
|
1114
1114
|
|
|
1115
1115
|
expect(isSameContent).to.be.true;
|
|
@@ -1128,7 +1128,7 @@ describe('MongoRepository', () => {
|
|
|
1128
1128
|
latestRecord = await subject.findLatest(SERVICE_PROVIDER_ID, TERMS_TYPE);
|
|
1129
1129
|
});
|
|
1130
1130
|
|
|
1131
|
-
it('returns null',
|
|
1131
|
+
it('returns null', () => {
|
|
1132
1132
|
expect(latestRecord).to.equal(null);
|
|
1133
1133
|
});
|
|
1134
1134
|
});
|
|
@@ -1177,13 +1177,13 @@ describe('MongoRepository', () => {
|
|
|
1177
1177
|
}
|
|
1178
1178
|
});
|
|
1179
1179
|
|
|
1180
|
-
after(
|
|
1180
|
+
after(() => subject.removeAll());
|
|
1181
1181
|
|
|
1182
|
-
it('iterates through all records',
|
|
1182
|
+
it('iterates through all records', () => {
|
|
1183
1183
|
expect(ids).to.have.members(expectedIds);
|
|
1184
1184
|
});
|
|
1185
1185
|
|
|
1186
|
-
it('iterates in ascending order',
|
|
1186
|
+
it('iterates in ascending order', () => {
|
|
1187
1187
|
expect(fetchDates).to.deep.equal([ FETCH_DATE_EARLIER, FETCH_DATE, FETCH_DATE_LATER ]);
|
|
1188
1188
|
});
|
|
1189
1189
|
});
|