From 4b1b4fd57f7b3d79582576a990d6ff2bc3d0c73b Mon Sep 17 00:00:00 2001 From: Henry Addison Date: Thu, 24 Oct 2019 14:05:46 +0100 Subject: [PATCH 1/2] add tests for imperativeConfiguration and validationMode these aren't yet added to the model specifications but based on the plan in https://github.com/openactive/data-models/issues/41 --- src/models-spec.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/models-spec.js b/src/models-spec.js index a2236322..955fa9b8 100644 --- a/src/models-spec.js +++ b/src/models-spec.js @@ -477,6 +477,32 @@ describe('models', () => { } }); }); + + describe('imperativeConfiguration', () => { + ['requiredFields', 'recommendedFields', 'shallNotInclude'].forEach((fieldRestriction) => { + describe(fieldRestriction, () => { + it('should only contain fields from inSpec', () => { + if (Object.prototype.hasOwnProperty.call(jsonData, 'imperativeConfiguration')) { + for (const config of Object.values(jsonData.imperativeConfiguration)) { + for (const fieldName of config[fieldRestriction]) { + expect(jsonData.inSpec).toContain(fieldName); + } + } + } + }); + }); + }); + }); + + describe('validationMode', () => { + it('should pointt to entries in imperativeConfiguration', () => { + if (Object.prototype.hasOwnProperty.call(jsonData, 'validationMode')) { + for (const imperativeConfigurationKey of Object.values(jsonData.validationMode)) { + expect(Object.keys(jsonData.imperativeConfiguration)).toContain(imperativeConfigurationKey); + } + } + }); + }); }); describe('namespaces', () => { From 75df1e7602e8e03fe761d02e462234aac3c55fd1 Mon Sep 17 00:00:00 2001 From: Henry Addison Date: Thu, 24 Oct 2019 14:28:39 +0100 Subject: [PATCH 2/2] fix typo in test description --- src/models-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models-spec.js b/src/models-spec.js index 955fa9b8..ecde6a09 100644 --- a/src/models-spec.js +++ b/src/models-spec.js @@ -495,7 +495,7 @@ describe('models', () => { }); describe('validationMode', () => { - it('should pointt to entries in imperativeConfiguration', () => { + it('should point to entries in imperativeConfiguration', () => { if (Object.prototype.hasOwnProperty.call(jsonData, 'validationMode')) { for (const imperativeConfigurationKey of Object.values(jsonData.validationMode)) { expect(Object.keys(jsonData.imperativeConfiguration)).toContain(imperativeConfigurationKey);