From 13691bdfa4225f842bf15d2f21350feaf1b2a85c Mon Sep 17 00:00:00 2001 From: notlee Date: Thu, 29 Apr 2021 09:48:12 +0100 Subject: [PATCH] Correct remaining tests for dropping the module component type --- test/unit/tasks/verify-origami-json.test.js | 31 +++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/test/unit/tasks/verify-origami-json.test.js b/test/unit/tasks/verify-origami-json.test.js index 7f7903b6..ccb118c1 100644 --- a/test/unit/tasks/verify-origami-json.test.js +++ b/test/unit/tasks/verify-origami-json.test.js @@ -206,9 +206,9 @@ describe('verify-origami-json', function () { }); }); - it('should fail if origamiType property is no or "service" or "imageset"', function () { + it('should fail if origamiType property is not supported', function () { const origamiJSON = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'origami.json'), 'utf-8')); - origamiJSON.origamiType = ''; + origamiJSON.origamiType = 'module'; fs.writeFileSync('origami.json', JSON.stringify(origamiJSON), 'utf8'); return verifyOrigamiJson().task() @@ -236,9 +236,9 @@ describe('verify-origami-json', function () { proclaim.notCalled(console.log); }); - it('should pass if origamiType property i', async function () { + it('should pass if origamiType property is "component', async function () { const origamiJSON = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'origami.json'), 'utf-8')); - origamiJSON.origamiType = 'module'; + origamiJSON.origamiType = 'component'; fs.writeFileSync('origami.json', JSON.stringify(origamiJSON), 'utf8'); await verifyOrigamiJson().task(); @@ -254,6 +254,27 @@ describe('verify-origami-json', function () { proclaim.notCalled(console.log); }); + it('should fail if origamiType property is "module"', function () { + const origamiJSON = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'origami.json'), 'utf-8')); + delete origamiJSON.origamiVersion; + fs.writeFileSync('origami.json', JSON.stringify(origamiJSON), 'utf8'); + + return verifyOrigamiJson().task() + .catch(function (verifiedOrigamiJson) { + proclaim.equal( + verifiedOrigamiJson.message, + 'Failed linting:\n\n' + + 'The origamiVersion property needs to be set to "2.0" or higher, this version of Origami Build tools only supports v2 of the Origami component specification.\n\n' + + 'The origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/' + ); + proclaim.calledOnce(console.log); + proclaim.calledWithExactly( + console.log, + `::error file=origami.json,line=1,col=1::Failed linting:%0A%0AThe origamiVersion property needs to be set to "2.0" or higher, this version of Origami Build tools only supports v2 of the Origami component specification.%0A%0AThe origami.json file does not conform to the specification at http://origami.ft.com/docs/syntax/origamijson/` + ); + }); + }); + it('should fail if missing origamiVersion property', function () { const origamiJSON = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'origami.json'), 'utf-8')); delete origamiJSON.origamiVersion; @@ -527,7 +548,7 @@ describe('verify-origami-json', function () { beforeEach(() => { origamiJSON = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'origami.json'), 'utf-8')); - origamiJSON.origamiType = 'module'; + origamiJSON.origamiType = 'component'; }); it('should fail when a demo does not have a title property', function () {