|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const ng = require('../helpers/ng'); |
| 4 | +const tmp = require('../helpers/tmp'); |
| 5 | + |
| 6 | +const conf = require('ember-cli/tests/helpers/conf'); |
| 7 | +const existsSync = require('exists-sync'); |
| 8 | +const expect = require('chai').expect; |
| 9 | +const path = require('path'); |
| 10 | +const root = process.cwd(); |
| 11 | + |
| 12 | +const testPath = path.join(root, 'tmp', 'foo', 'src', 'app'); |
| 13 | + |
| 14 | +describe('Acceptance: ng generate module', function () { |
| 15 | + before(conf.setup); |
| 16 | + |
| 17 | + after(conf.restore); |
| 18 | + |
| 19 | + beforeEach(function () { |
| 20 | + return tmp.setup('./tmp').then(function () { |
| 21 | + process.chdir('./tmp'); |
| 22 | + }).then(function () { |
| 23 | + return ng(['new', 'foo', '--skip-npm', '--skip-bower']); |
| 24 | + }); |
| 25 | + }); |
| 26 | + |
| 27 | + afterEach(function () { |
| 28 | + this.timeout(10000); |
| 29 | + |
| 30 | + return tmp.teardown('./tmp'); |
| 31 | + }); |
| 32 | + |
| 33 | + it('ng generate module my-module', function () { |
| 34 | + return ng(['generate', 'module', 'my-module']).then(() => { |
| 35 | + expect(existsSync(path.join(testPath, 'my-module.module.ts'))).to.equal(true); |
| 36 | + expect(existsSync(path.join(testPath, 'my-module.module.spec.ts'))).to.equal(false); |
| 37 | + }); |
| 38 | + }); |
| 39 | + |
| 40 | + it('ng generate module my-module --spec', function () { |
| 41 | + return ng(['generate', 'module', 'my-module', '--spec']).then(() => { |
| 42 | + expect(existsSync(path.join(testPath, 'my-module.module.ts'))).to.equal(true); |
| 43 | + expect(existsSync(path.join(testPath, 'my-module.module.spec.ts'))).to.equal(true); |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + it(`ng generate module shared${path.sep}my-module`, function () { |
| 48 | + return ng(['generate', 'module', 'shared/my-module']).then(() => { |
| 49 | + expect(existsSync(path.join(testPath, 'shared', 'my-module.module.ts'))).to.equal(true); |
| 50 | + expect(existsSync(path.join(testPath, 'shared', 'my-module.module.spec.ts'))).to.equal(false); |
| 51 | + }); |
| 52 | + }); |
| 53 | + |
| 54 | + it(`ng generate module shared${path.sep}my-module --spec`, function () { |
| 55 | + return ng(['generate', 'module', 'shared/my-module', '--spec']).then(() => { |
| 56 | + expect(existsSync(path.join(testPath, 'shared', 'my-module.module.ts'))).to.equal(true); |
| 57 | + expect(existsSync(path.join(testPath, 'shared', 'my-module.module.spec.ts'))).to.equal(true); |
| 58 | + }); |
| 59 | + }); |
| 60 | +}); |
0 commit comments