@opentermsarchive/engine 10.6.0 → 10.6.1
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
|
@@ -50,6 +50,10 @@ export default class DeclarationUtils {
|
|
|
50
50
|
if (modifiedFilePath.endsWith('.filters.js') || modifiedFilePath.endsWith('.filters.history.js')) {
|
|
51
51
|
const declaration = await this.getJSONFromFile(this.defaultBranch, `declarations/${serviceId}.json`);
|
|
52
52
|
|
|
53
|
+
if (!declaration) { // Happens when the file declaration exists in the branch but not in the default branch
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
53
57
|
servicesTermsTypes[serviceId] = Object.keys(declaration.terms); // Considering how rarely filters are used, simply return all term types that could potentially be impacted to spare implementing a function change check
|
|
54
58
|
|
|
55
59
|
return;
|
|
@@ -188,6 +188,23 @@ describe('DeclarationUtils', () => {
|
|
|
188
188
|
});
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
+
context('when a new declaration has been added along with a filters file', () => {
|
|
192
|
+
before(async () => {
|
|
193
|
+
await fs.writeFile(path.resolve(SUBJECT_PATH, COMMIT_PATHS.serviceB), JSON.stringify(FIXTURES.serviceB.content, null, 2));
|
|
194
|
+
await fs.writeFile(path.resolve(SUBJECT_PATH, './declarations/ServiceB.filters.js'), 'module.exports = {};');
|
|
195
|
+
await declarationUtils.git.add([ COMMIT_PATHS.serviceB, './declarations/ServiceB.filters.js' ]);
|
|
196
|
+
await declarationUtils.git.commit('Add declaration with filters for new service');
|
|
197
|
+
});
|
|
198
|
+
after(removeLatestCommit);
|
|
199
|
+
|
|
200
|
+
it('returns the added service ID along with all its terms types', async () => {
|
|
201
|
+
expect(await declarationUtils.getModifiedServicesAndTermsTypes()).to.deep.equal({
|
|
202
|
+
services: ['ServiceB'],
|
|
203
|
+
servicesTermsTypes: { ServiceB: ['Terms of Service'] },
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
191
208
|
context('when history file is modified without declaration changes', () => {
|
|
192
209
|
before(() => commitChanges(COMMIT_PATHS.serviceAHistory, FIXTURES.serviceATermsUpdatedHistory.content));
|
|
193
210
|
after(removeLatestCommit);
|