Skip to content

Commit bb42e57

Browse files
major-winterTC
authored and
TC
committed
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 <[email protected]>
1 parent 500e20b commit bb42e57

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Diff for: packages/cli/test/integration/generators/controller.integration.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ const {expectFileToMatchSnapshot} = require('../../snapshots');
2424
const sandbox = new TestSandbox(path.resolve(__dirname, '../.sandbox'));
2525

2626
// CLI Inputs
27+
const defaultCLIInput = {
28+
name: 'productReview',
29+
};
2730
const basicCLIInput = {
2831
name: 'productReview',
32+
controllerType: 'ControllerGenerator.BASIC',
2933
};
3034
const restCLIInput = {
3135
name: 'productReview',
@@ -54,7 +58,7 @@ describe('lb4 controller', () => {
5458
.inDir(sandbox.path, () =>
5559
testUtils.givenLBProject(sandbox.path, {excludePackageJSON: true}),
5660
)
57-
.withPrompts(basicCLIInput),
61+
.withPrompts(defaultCLIInput),
5862
).to.be.rejectedWith(/No package.json found in/);
5963
});
6064

@@ -65,12 +69,21 @@ describe('lb4 controller', () => {
6569
.inDir(sandbox.path, () =>
6670
testUtils.givenLBProject(sandbox.path, {excludeLoopbackCore: true}),
6771
)
68-
.withPrompts(basicCLIInput),
72+
.withPrompts(defaultCLIInput),
6973
).to.be.rejectedWith(/No `@loopback\/core` package found/);
7074
});
7175

7276
describe('basic controller', () => {
7377
it('scaffolds correct file with input', async () => {
78+
await testUtils
79+
.executeGenerator(generator)
80+
.inDir(sandbox.path, () => testUtils.givenLBProject(sandbox.path))
81+
.withPrompts(defaultCLIInput);
82+
83+
checkBasicContents();
84+
});
85+
86+
it('scaffolds correct file with controllerType BASIC specified explicitly', async () => {
7487
await testUtils
7588
.executeGenerator(generator)
7689
.inDir(sandbox.path, () => testUtils.givenLBProject(sandbox.path))

0 commit comments

Comments
 (0)