|
1 | 1 | // tslint:disable:max-line-length
|
2 |
| -import { mkdirsSync, pathExistsSync, readFile, readFileSync } from 'fs-extra'; |
| 2 | +import { mkdirsSync, pathExistsSync, readFile, readFileSync, writeFileSync } from 'fs-extra'; |
3 | 3 | import * as path from 'path';
|
4 | 4 | import { ng, setupProject } from '../helpers';
|
5 | 5 |
|
@@ -345,5 +345,22 @@ describe('Acceptance: ng generate component', () => {
|
345 | 345 | })
|
346 | 346 | .then(done, done.fail);
|
347 | 347 | });
|
| 348 | + |
| 349 | + describe('should generate components in apps with empty appRoot', () => { |
| 350 | + it('should work', (done) => { |
| 351 | + const appRoot = path.join(root, 'tmp/foo'); |
| 352 | + mkdirsSync(path.join(appRoot, 'other', 'src')); |
| 353 | + |
| 354 | + return ng(['generate', 'module', 'm', '--app', 'other']).then(() => { |
| 355 | + const expectedModule = path.join(appRoot, 'other', 'src', 'm', 'm.module.ts'); |
| 356 | + expect(pathExistsSync(expectedModule)).toBe(true); |
| 357 | + |
| 358 | + return ng(['generate', 'component', 'm/c', '--app', 'other', '--module', 'm']).then(() => { |
| 359 | + expect(pathExistsSync(path.join(appRoot, 'other', 'src', 'm', 'c', 'c.component.ts'))).toBe(true); |
| 360 | + expect(readFileSync(expectedModule, 'utf-8')).toContain(`import { CComponent } from './c/c.component'`); |
| 361 | + }); |
| 362 | + }).then(done, done.fail); |
| 363 | + }); |
| 364 | + }); |
348 | 365 | });
|
349 | 366 | });
|
0 commit comments