Skip to content

Commit b5d3204

Browse files
AhsanAyazBrocco
authored andcommitted
test(@angular/cli): added unit test for styles extension
1 parent 4d0c93e commit b5d3204

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/acceptance/generate-component.spec.ts

+16
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,22 @@ describe('Acceptance: ng generate component', () => {
7373
.then(done, done.fail);
7474
});
7575

76+
it('mycomp should use styleExt from the angular-cli.json for style file', (done) => {
77+
return ng(['generate', 'component', 'mycomp']).then(() => {
78+
const cliJson = JSON.parse(readFileSync('.angular-cli.json', 'utf8'));
79+
const styleExt = cliJson.defaults.styleExt;
80+
expect(styleExt).toBe('css');
81+
const scssFilePath =
82+
path.join(root, 'tmp', 'foo', 'src', 'app', 'mycomp', `mycomp.component.${styleExt}`);
83+
const compPath =
84+
path.join(root, 'tmp', 'foo', 'src', 'app', 'mycomp', 'mycomp.component.ts');
85+
expect(pathExistsSync(scssFilePath)).toBe(true);
86+
const contents = readFileSync(compPath, 'utf8');
87+
expect(contents.indexOf(`styleUrls: [\'./mycomp.component.${styleExt}\']`) === -1).toBe(false);
88+
})
89+
.then(done, done.fail);
90+
});
91+
7692
it('child-dir' + path.sep + 'my-comp from a child dir', (done) => {
7793
mkdirsSync(path.join(root, 'tmp', 'foo', 'src', 'app', '1', 'child-dir'));
7894
return new Promise(function (resolve) {

0 commit comments

Comments
 (0)