|
2 | 2 |
|
3 | 3 | const ng = require('../helpers/ng');
|
4 | 4 | const tmp = require('../helpers/tmp');
|
5 |
| - |
| 5 | +const fs = require('fs-extra'); |
6 | 6 | const existsSync = require('exists-sync');
|
7 | 7 | const expect = require('chai').expect;
|
| 8 | +const Promise = require('angular-cli/ember-cli/lib/ext/promise'); |
8 | 9 | const path = require('path');
|
9 | 10 | const root = process.cwd();
|
10 | 11 |
|
@@ -40,7 +41,7 @@ describe('Acceptance: ng generate module', function () {
|
40 | 41 | });
|
41 | 42 |
|
42 | 43 | it('ng generate module generate routing and component files when passed flag --routing', function () {
|
43 |
| - return ng(['generate', 'module', 'my-module', '--routing']).then( () => { |
| 44 | + return ng(['generate', 'module', 'my-module', '--routing']).then(() => { |
44 | 45 | expect(existsSync(path.join(testPath, 'my-module', 'my-module.module.ts'))).to.equal(true);
|
45 | 46 | expect(existsSync(path.join(testPath, 'my-module', 'my-module-routing.module.ts'))).to.equal(true);
|
46 | 47 | expect(existsSync(path.join(testPath, 'my-module', 'my-module.module.spec.ts'))).to.equal(false);
|
@@ -72,6 +73,35 @@ describe('Acceptance: ng generate module', function () {
|
72 | 73 | );
|
73 | 74 | });
|
74 | 75 |
|
| 76 | + it('ng generate module child should work in sub-dir', function () { |
| 77 | + fs.mkdirSync(path.join(testPath, './sub-dir')); |
| 78 | + return new Promise(resolve => { |
| 79 | + process.chdir(path.join(testPath, './sub-dir')); |
| 80 | + return resolve(); |
| 81 | + }).then(() => |
| 82 | + ng(['generate', 'module', 'child']).then(() => { |
| 83 | + expect(existsSync(path.join(testPath, 'sub-dir/child', 'child.module.ts'))).to.equal(true); |
| 84 | + expect(existsSync(path.join(testPath, 'sub-dir/child', 'child.module.spec.ts'))).to.equal(false); |
| 85 | + expect(existsSync(path.join(testPath, 'sub-dir/child', 'child.component.ts'))).to.equal(false); |
| 86 | + }) |
| 87 | + ); |
| 88 | + }); |
| 89 | + |
| 90 | + it('ng generate module child should work in sub-dir with routing and component files when passed --routing flag', function () { |
| 91 | + fs.mkdirSync(path.join(testPath, './sub-dir')); |
| 92 | + return new Promise(resolve => { |
| 93 | + process.chdir(path.join(testPath, './sub-dir')); |
| 94 | + return resolve(); |
| 95 | + }).then(() => |
| 96 | + ng(['generate', 'module', 'child', '--routing']).then(() => { |
| 97 | + expect(existsSync(path.join(testPath, 'sub-dir/child', 'child.module.ts'))).to.equal(true); |
| 98 | + expect(existsSync(path.join(testPath, 'sub-dir/child', 'child-routing.module.ts'))).to.equal(true); |
| 99 | + expect(existsSync(path.join(testPath, 'sub-dir/child', 'child.module.spec.ts'))).to.equal(false); |
| 100 | + expect(existsSync(path.join(testPath, 'sub-dir/child', 'child.component.ts'))).to.equal(true); |
| 101 | + }) |
| 102 | + ); |
| 103 | + }); |
| 104 | + |
75 | 105 | it('ng generate module should generate parent/child module with routing and component files when passed --routing flag', function () {
|
76 | 106 | return ng(['generate', 'module', 'parent']).then(() =>
|
77 | 107 | ng(['generate', 'module', 'parent/child', '--routing']).then(() => {
|
|
0 commit comments