@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
|
@@ -20,14 +20,14 @@ describe('Snapshot', () => {
|
|
|
20
20
|
|
|
21
21
|
describe(`"${requiredParam}"`, () => {
|
|
22
22
|
context('when missing', () => {
|
|
23
|
-
it('throws an error',
|
|
23
|
+
it('throws an error', () => {
|
|
24
24
|
subject = new Snapshot({ ...validParamsExceptTheOneTested });
|
|
25
25
|
expect(subject.validate.bind(subject)).to.throw(RegExp(requiredParam));
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
context('when null', () => {
|
|
30
|
-
it('throws an error',
|
|
30
|
+
it('throws an error', () => {
|
|
31
31
|
subject = new Snapshot({ ...validParamsExceptTheOneTested, [requiredParam]: null });
|
|
32
32
|
expect(subject.validate.bind(subject)).to.throw(RegExp(requiredParam));
|
|
33
33
|
});
|
|
@@ -44,12 +44,12 @@ describe('Snapshot', () => {
|
|
|
44
44
|
fetchDate: new Date('2000-01-01T12:00:00.000Z'),
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
before(
|
|
47
|
+
before(() => {
|
|
48
48
|
subject = new Snapshot(recordParams);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
context('when it is neither defined nor loaded', () => {
|
|
52
|
-
it('throws an error explaining how to recover',
|
|
52
|
+
it('throws an error explaining how to recover', () => {
|
|
53
53
|
try {
|
|
54
54
|
console.log(subject.content);
|
|
55
55
|
} catch (e) {
|
|
@@ -20,14 +20,14 @@ describe('Version', () => {
|
|
|
20
20
|
|
|
21
21
|
describe(`"${requiredParam}"`, () => {
|
|
22
22
|
context('when missing', () => {
|
|
23
|
-
it('throws an error',
|
|
23
|
+
it('throws an error', () => {
|
|
24
24
|
subject = new Version({ ...validParamsExceptTheOneTested });
|
|
25
25
|
expect(subject.validate.bind(subject)).to.throw(RegExp(requiredParam));
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
context('when null', () => {
|
|
30
|
-
it('throws an error',
|
|
30
|
+
it('throws an error', () => {
|
|
31
31
|
subject = new Version({ ...validParamsExceptTheOneTested, [requiredParam]: null });
|
|
32
32
|
expect(subject.validate.bind(subject)).to.throw(RegExp(requiredParam));
|
|
33
33
|
});
|
|
@@ -44,12 +44,12 @@ describe('Version', () => {
|
|
|
44
44
|
snapshotIds: ['dd263f270b3065e1c18201b49ab898474b357566'],
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
before(
|
|
47
|
+
before(() => {
|
|
48
48
|
subject = new Version(recordParams);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
context('when it is neither defined nor loaded', () => {
|
|
52
|
-
it('throws an error explaining how to recover',
|
|
52
|
+
it('throws an error explaining how to recover', () => {
|
|
53
53
|
try {
|
|
54
54
|
console.log(subject.content);
|
|
55
55
|
} catch (e) {
|
|
@@ -12,7 +12,7 @@ describe('Services', () => {
|
|
|
12
12
|
describe('#load', () => {
|
|
13
13
|
let result;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
function validateServiceWithoutHistory(serviceId, expected) {
|
|
16
16
|
/* eslint-disable no-loop-func */
|
|
17
17
|
for (const termsType of expected.getTermsTypes()) {
|
|
18
18
|
context(`${termsType}`, () => {
|
|
@@ -59,20 +59,20 @@ describe('Services', () => {
|
|
|
59
59
|
expect(actualTerms.validUntil).to.be.undefined;
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
it('has the proper content selectors',
|
|
62
|
+
it('has the proper content selectors', () => {
|
|
63
63
|
expect(actualContentSelectors).to.equal(expectedContentSelectors);
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
it('has the proper insignificant content selectors',
|
|
66
|
+
it('has the proper insignificant content selectors', () => {
|
|
67
67
|
expect(actualInsignificantContentSelectors).to.equal(expectedInsignificantContentSelectors);
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
it('has the proper executeClientScripts option',
|
|
70
|
+
it('has the proper executeClientScripts option', () => {
|
|
71
71
|
expect(actualExecuteClientScripts).to.equal(expectedExecuteClientScripts);
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
if (expectedFilters) {
|
|
75
|
-
it('has the proper number of filter functions',
|
|
75
|
+
it('has the proper number of filter functions', () => {
|
|
76
76
|
expect(actualFilters.length).to.equal(expectedFilters.length);
|
|
77
77
|
});
|
|
78
78
|
|
|
@@ -125,12 +125,12 @@ describe('Services', () => {
|
|
|
125
125
|
await validateServiceWithoutHistory('service_with_multiple_source_documents_terms', expectedServices.service_with_multiple_source_documents_terms);
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
-
context('when specifying services to load',
|
|
128
|
+
context('when specifying services to load', () => {
|
|
129
129
|
before(async () => {
|
|
130
130
|
result = await services.load([ 'service·A', 'Service B!' ]);
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
-
it('loads only the given services',
|
|
133
|
+
it('loads only the given services', () => {
|
|
134
134
|
expect(result).to.have.all.keys('service·A', 'Service B!');
|
|
135
135
|
});
|
|
136
136
|
});
|
|
@@ -139,7 +139,7 @@ describe('Services', () => {
|
|
|
139
139
|
describe('#loadWithHistory', () => {
|
|
140
140
|
let result;
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
function validateServiceWithHistory(serviceId, expected) {
|
|
143
143
|
/* eslint-disable no-loop-func */
|
|
144
144
|
for (const termsType of expected.getTermsTypes()) {
|
|
145
145
|
context(`${termsType}`, () => {
|
|
@@ -201,20 +201,20 @@ describe('Services', () => {
|
|
|
201
201
|
} = actualDocumentsForThisDate[index]);
|
|
202
202
|
});
|
|
203
203
|
|
|
204
|
-
it('has the proper content selectors',
|
|
204
|
+
it('has the proper content selectors', () => {
|
|
205
205
|
expect(contentSelectorsForThisDate).to.equal(expectedContentSelectors);
|
|
206
206
|
});
|
|
207
207
|
|
|
208
|
-
it('has the proper insignificant content selectors',
|
|
208
|
+
it('has the proper insignificant content selectors', () => {
|
|
209
209
|
expect(insignificantContentSelectorsForThisDate).to.equal(expectedInsignificantContentSelectors);
|
|
210
210
|
});
|
|
211
211
|
|
|
212
|
-
it('has the proper executeClientScripts option',
|
|
212
|
+
it('has the proper executeClientScripts option', () => {
|
|
213
213
|
expect(actualExecuteClientScriptsForThisDate).to.equal(expectedExecuteClientScriptsForThisDate);
|
|
214
214
|
});
|
|
215
215
|
|
|
216
216
|
if (expectedFiltersForThisDate) {
|
|
217
|
-
it('has the proper number of filter functions',
|
|
217
|
+
it('has the proper number of filter functions', () => {
|
|
218
218
|
expect(actualFiltersForThisDate.length).to.equal(expectedFiltersForThisDate.length);
|
|
219
219
|
});
|
|
220
220
|
|
|
@@ -231,12 +231,12 @@ describe('Services', () => {
|
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
233
|
} else {
|
|
234
|
-
it('has no history',
|
|
234
|
+
it('has no history', () => {
|
|
235
235
|
expect(actualTerms.validUntil).to.be.undefined;
|
|
236
236
|
});
|
|
237
237
|
|
|
238
238
|
if (expectedFilters) {
|
|
239
|
-
it('has the proper number of filter functions',
|
|
239
|
+
it('has the proper number of filter functions', () => {
|
|
240
240
|
expect(actualFilters.length).to.equal(expectedFilters.length);
|
|
241
241
|
});
|
|
242
242
|
|
|
@@ -294,12 +294,12 @@ describe('Services', () => {
|
|
|
294
294
|
await validateServiceWithHistory('service_with_multiple_source_documents_terms', expectedServices.service_with_multiple_source_documents_terms);
|
|
295
295
|
});
|
|
296
296
|
|
|
297
|
-
context('when specifying services to load',
|
|
297
|
+
context('when specifying services to load', () => {
|
|
298
298
|
before(async () => {
|
|
299
299
|
result = await services.loadWithHistory([ 'service·A', 'Service B!' ]);
|
|
300
300
|
});
|
|
301
301
|
|
|
302
|
-
it('loads only the given services',
|
|
302
|
+
it('loads only the given services', () => {
|
|
303
303
|
expect(result).to.have.all.keys('service·A', 'Service B!');
|
|
304
304
|
});
|
|
305
305
|
});
|
|
@@ -10,7 +10,7 @@ describe('SourceDocument', () => {
|
|
|
10
10
|
describe('#getCssSelectors', () => {
|
|
11
11
|
context('with "select" property', () => {
|
|
12
12
|
context('with string selector', () => {
|
|
13
|
-
it('extracts selectors',
|
|
13
|
+
it('extracts selectors', () => {
|
|
14
14
|
const result = new SourceDocument({ location: URL, contentSelectors: 'body' }).cssSelectors;
|
|
15
15
|
|
|
16
16
|
expect(result).to.deep.equal(['body']);
|
|
@@ -18,7 +18,7 @@ describe('SourceDocument', () => {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
context('with range selector', () => {
|
|
21
|
-
it('extracts selectors',
|
|
21
|
+
it('extracts selectors', () => {
|
|
22
22
|
const result = new SourceDocument({
|
|
23
23
|
location: URL,
|
|
24
24
|
contentSelectors: {
|
|
@@ -32,7 +32,7 @@ describe('SourceDocument', () => {
|
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
context('with an array of mixed selectors', () => {
|
|
35
|
-
it('extracts selectors',
|
|
35
|
+
it('extracts selectors', () => {
|
|
36
36
|
const result = new SourceDocument({
|
|
37
37
|
location: URL,
|
|
38
38
|
contentSelectors: [
|
|
@@ -51,7 +51,7 @@ describe('SourceDocument', () => {
|
|
|
51
51
|
|
|
52
52
|
context('with "remove" property', () => {
|
|
53
53
|
context('with string selector', () => {
|
|
54
|
-
it('extracts selectors',
|
|
54
|
+
it('extracts selectors', () => {
|
|
55
55
|
const result = new SourceDocument({ location: URL, insignificantContentSelectors: 'body' }).cssSelectors;
|
|
56
56
|
|
|
57
57
|
expect(result).to.deep.equal(['body']);
|
|
@@ -59,7 +59,7 @@ describe('SourceDocument', () => {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
context('with range selector', () => {
|
|
62
|
-
it('extracts selectors',
|
|
62
|
+
it('extracts selectors', () => {
|
|
63
63
|
const result = new SourceDocument({
|
|
64
64
|
location: URL,
|
|
65
65
|
insignificantContentSelectors: {
|
|
@@ -73,7 +73,7 @@ describe('SourceDocument', () => {
|
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
context('with an array of mixed selectors', () => {
|
|
76
|
-
it('extracts selectors',
|
|
76
|
+
it('extracts selectors', () => {
|
|
77
77
|
const result = new SourceDocument({
|
|
78
78
|
location: URL,
|
|
79
79
|
insignificantContentSelectors: [
|
|
@@ -92,7 +92,7 @@ describe('SourceDocument', () => {
|
|
|
92
92
|
|
|
93
93
|
context('with both "select" and "remove" property', () => {
|
|
94
94
|
context('with string selector', () => {
|
|
95
|
-
it('extracts selectors',
|
|
95
|
+
it('extracts selectors', () => {
|
|
96
96
|
const result = new SourceDocument({
|
|
97
97
|
location: URL,
|
|
98
98
|
contentSelectors: 'body',
|
|
@@ -104,7 +104,7 @@ describe('SourceDocument', () => {
|
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
context('with range selector', () => {
|
|
107
|
-
it('extracts selectors',
|
|
107
|
+
it('extracts selectors', () => {
|
|
108
108
|
const result = new SourceDocument({
|
|
109
109
|
location: URL,
|
|
110
110
|
contentSelectors: {
|
|
@@ -127,7 +127,7 @@ describe('SourceDocument', () => {
|
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
context('with an array of mixed selectors', () => {
|
|
130
|
-
it('extracts selectors',
|
|
130
|
+
it('extracts selectors', () => {
|
|
131
131
|
const result = new SourceDocument({
|
|
132
132
|
location: URL,
|
|
133
133
|
contentSelectors: [
|
|
@@ -160,7 +160,7 @@ describe('SourceDocument', () => {
|
|
|
160
160
|
});
|
|
161
161
|
|
|
162
162
|
describe('#toPersistence', () => {
|
|
163
|
-
it('converts basic source document declarations into JSON representation',
|
|
163
|
+
it('converts basic source document declarations into JSON representation', () => {
|
|
164
164
|
const result = new SourceDocument({
|
|
165
165
|
location: URL,
|
|
166
166
|
contentSelectors: 'body',
|
|
@@ -177,7 +177,7 @@ describe('SourceDocument', () => {
|
|
|
177
177
|
expect(result).to.deep.equal(expectedResult);
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
-
it('converts full source document declarations to JSON representation',
|
|
180
|
+
it('converts full source document declarations to JSON representation', () => {
|
|
181
181
|
const result = new SourceDocument({
|
|
182
182
|
location: URL,
|
|
183
183
|
contentSelectors: [
|
|
@@ -60,7 +60,7 @@ describe('Terms', () => {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
describe('#toPersistence', () => {
|
|
63
|
-
it('converts terms with single source document to JSON representation',
|
|
63
|
+
it('converts terms with single source document to JSON representation', () => {
|
|
64
64
|
const result = new Terms({ service, type: termsType, sourceDocuments: [document1] }).toPersistence();
|
|
65
65
|
|
|
66
66
|
const expectedResult = {
|
|
@@ -71,7 +71,7 @@ describe('Terms', () => {
|
|
|
71
71
|
expect(result).to.deep.equal(expectedResult);
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
it('converts terms with multiple source documents to JSON representation',
|
|
74
|
+
it('converts terms with multiple source documents to JSON representation', () => {
|
|
75
75
|
const result = new Terms({ service, type: termsType, sourceDocuments: [ document1, document2 ] }).toPersistence();
|
|
76
76
|
|
|
77
77
|
const expectedResult = {
|
package/src/notifier/index.js
CHANGED
|
@@ -17,11 +17,11 @@ export default class Notifier {
|
|
|
17
17
|
this.delayedVersionNotificationsParams = [];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
onVersionRecorded(record) {
|
|
21
21
|
this.delayedVersionNotificationsParams.push(record);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
onTrackingCompleted() {
|
|
25
25
|
this.delayedVersionNotificationsParams.forEach(async ({ serviceId, termsType, id }) => {
|
|
26
26
|
try {
|
|
27
27
|
await this.notifyVersionRecorded(serviceId, termsType, id);
|