Skip to content

Commit

Permalink
fix: add a unit test
Browse files Browse the repository at this point in the history
Add a unit test that verifies the scaffold when explicity specifying the controller type as BASIC

Signed-off-by: TC <[email protected]>
  • Loading branch information
major-winter authored and Chu committed Aug 20, 2024
1 parent 500e20b commit 860b036
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
1 change: 0 additions & 1 deletion CODE_OF_CONDUCT.md

This file was deleted.

1 change: 1 addition & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./docs/CODE_OF_CONDUCT.md
1 change: 0 additions & 1 deletion CONTRIBUTING.md

This file was deleted.

1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./docs/CONTRIBUTING.md
1 change: 0 additions & 1 deletion MAINTAINING.md

This file was deleted.

1 change: 1 addition & 0 deletions MAINTAINING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./docs/MAINTAINING.md
17 changes: 15 additions & 2 deletions packages/cli/test/integration/generators/controller.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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/);
});

Expand All @@ -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))
Expand Down

0 comments on commit 860b036

Please sign in to comment.