@opentermsarchive/engine 14.0.0 → 14.1.0
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
CHANGED
|
@@ -118,6 +118,14 @@ export default async options => {
|
|
|
118
118
|
describe(type, () => {
|
|
119
119
|
const terms = service.getTerms({ type });
|
|
120
120
|
|
|
121
|
+
if (terms.hasMultipleSourceDocuments) {
|
|
122
|
+
it('does not declare the same source document more than once', () => {
|
|
123
|
+
const duplicateLocations = [...new Set(terms.duplicateSourceDocuments.map(sourceDocument => sourceDocument.location))];
|
|
124
|
+
|
|
125
|
+
expect(duplicateLocations, `The same source document is declared more than once within the "${type}" combine: ${duplicateLocations.join(', ')}`).to.be.empty;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
121
129
|
terms.sourceDocuments.forEach(sourceDocument => {
|
|
122
130
|
let filteredContent;
|
|
123
131
|
|
|
@@ -13,6 +13,18 @@ export default class Terms {
|
|
|
13
13
|
return this.sourceDocuments.length > 1;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
get duplicateSourceDocuments() {
|
|
17
|
+
const seenLocations = new Set();
|
|
18
|
+
|
|
19
|
+
return this.sourceDocuments.filter(({ location }) => {
|
|
20
|
+
const isDuplicate = seenLocations.has(location);
|
|
21
|
+
|
|
22
|
+
seenLocations.add(location);
|
|
23
|
+
|
|
24
|
+
return isDuplicate;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
16
28
|
toPersistence() {
|
|
17
29
|
return {
|
|
18
30
|
name: this.service.name,
|
|
@@ -80,4 +80,12 @@ describe('Terms', () => {
|
|
|
80
80
|
expect(result).to.deep.equal(expectedResult);
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
|
+
|
|
84
|
+
describe('#duplicateSourceDocuments', () => {
|
|
85
|
+
it('returns the source documents that repeat a location', () => {
|
|
86
|
+
const terms = new Terms({ service, type: termsType, sourceDocuments: [ document1, document2 ] });
|
|
87
|
+
|
|
88
|
+
expect(terms.duplicateSourceDocuments).to.deep.equal([document2]);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
83
91
|
});
|