Skip to content

Commit b0bd2ff

Browse files
timdeschryverbrandonroberts
authored andcommitted
feat(schematics): add standalone flag
1 parent 0319690 commit b0bd2ff

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

modules/schematics/src/container/index.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,28 @@ describe('Container Schematic', () => {
154154
/import { Store, StoreModule } from '@ngrx\/store';/
155155
);
156156
});
157+
158+
describe('standalone', () => {
159+
it('should be disabled by default', async () => {
160+
const options = { ...defaultOptions, standalone: false };
161+
const tree = await schematicRunner
162+
.runSchematicAsync('container', options, appTree)
163+
.toPromise();
164+
const content = tree.readContent(
165+
`${projectPath}/src/app/foo/foo.component.ts`
166+
);
167+
expect(content).not.toMatch(/standalone: true/);
168+
});
169+
170+
it('should create a standalone component if true', async () => {
171+
const options = { ...defaultOptions, standalone: true };
172+
const tree = await schematicRunner
173+
.runSchematicAsync('container', options, appTree)
174+
.toPromise();
175+
const content = tree.readContent(
176+
`${projectPath}/src/app/foo/foo.component.ts`
177+
);
178+
expect(content).toMatch(/standalone: true/);
179+
});
180+
});
157181
});

modules/schematics/src/container/schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@
9999
"enum": ["unit", "integration"],
100100
"type": "string",
101101
"default": "integration"
102+
},
103+
"standalone": {
104+
"description": "Whether the generated component is standalone.",
105+
"type": "boolean"
102106
}
103107
},
104108
"required": []

modules/schematics/src/container/schema.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,9 @@ export interface Schema {
7373
* Specifies whether to create a unit test or an integration test.
7474
*/
7575
testDepth?: string;
76+
77+
/**
78+
* Whether the generated component is standalone
79+
*/
80+
standalone?: boolean;
7681
}

0 commit comments

Comments
 (0)