From 860b036fd004e404d603af1d6fbace17306e2c23 Mon Sep 17 00:00:00 2001 From: TC Date: Sat, 10 Aug 2024 21:36:33 +0700 Subject: [PATCH] fix: add a unit test Add a unit test that verifies the scaffold when explicity specifying the controller type as BASIC Signed-off-by: TC --- CODE_OF_CONDUCT.md | 2 +- CONTRIBUTING.md | 2 +- MAINTAINING.md | 2 +- .../generators/controller.integration.js | 17 +++++++++++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) mode change 120000 => 100644 CODE_OF_CONDUCT.md mode change 120000 => 100644 CONTRIBUTING.md mode change 120000 => 100644 MAINTAINING.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 120000 index ef8d6e39760c..000000000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1 +0,0 @@ -./docs/CODE_OF_CONDUCT.md \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000000..9c5f15417747 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1 @@ +./docs/CODE_OF_CONDUCT.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 120000 index 6be9d5a007a9..000000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1 +0,0 @@ -./docs/CONTRIBUTING.md \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000000..69099262bf70 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +./docs/CONTRIBUTING.md diff --git a/MAINTAINING.md b/MAINTAINING.md deleted file mode 120000 index 1fa724a99b78..000000000000 --- a/MAINTAINING.md +++ /dev/null @@ -1 +0,0 @@ -./docs/MAINTAINING.md \ No newline at end of file diff --git a/MAINTAINING.md b/MAINTAINING.md new file mode 100644 index 000000000000..e62a31203624 --- /dev/null +++ b/MAINTAINING.md @@ -0,0 +1 @@ +./docs/MAINTAINING.md diff --git a/packages/cli/test/integration/generators/controller.integration.js b/packages/cli/test/integration/generators/controller.integration.js index 08bfbd923594..760b25c0fb41 100644 --- a/packages/cli/test/integration/generators/controller.integration.js +++ b/packages/cli/test/integration/generators/controller.integration.js @@ -24,8 +24,12 @@ const {expectFileToMatchSnapshot} = require('../../snapshots'); const sandbox = new TestSandbox(path.resolve(__dirname, '../.sandbox')); // CLI Inputs +const defaultCLIInput = { + name: 'productReview', +}; const basicCLIInput = { name: 'productReview', + controllerType: 'ControllerGenerator.BASIC', }; const restCLIInput = { name: 'productReview', @@ -54,7 +58,7 @@ describe('lb4 controller', () => { .inDir(sandbox.path, () => testUtils.givenLBProject(sandbox.path, {excludePackageJSON: true}), ) - .withPrompts(basicCLIInput), + .withPrompts(defaultCLIInput), ).to.be.rejectedWith(/No package.json found in/); }); @@ -65,12 +69,21 @@ describe('lb4 controller', () => { .inDir(sandbox.path, () => testUtils.givenLBProject(sandbox.path, {excludeLoopbackCore: true}), ) - .withPrompts(basicCLIInput), + .withPrompts(defaultCLIInput), ).to.be.rejectedWith(/No `@loopback\/core` package found/); }); describe('basic controller', () => { it('scaffolds correct file with input', async () => { + await testUtils + .executeGenerator(generator) + .inDir(sandbox.path, () => testUtils.givenLBProject(sandbox.path)) + .withPrompts(defaultCLIInput); + + checkBasicContents(); + }); + + it('scaffolds correct file with controllerType BASIC specified explicitly', async () => { await testUtils .executeGenerator(generator) .inDir(sandbox.path, () => testUtils.givenLBProject(sandbox.path))