|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const fs = require('fs'); |
| 4 | +const path = require('path'); |
| 5 | +const { |
| 6 | + setupTestHooks, |
| 7 | + emberNew, |
| 8 | + emberGenerate |
| 9 | +} = require('ember-cli-blueprint-test-helpers/helpers'); |
| 10 | +const { expect, file } = require('ember-cli-blueprint-test-helpers/chai'); |
| 11 | + |
| 12 | +describe('Acceptance: ember-cli-typescript generator', function() { |
| 13 | + setupTestHooks(this); |
| 14 | + |
| 15 | + it('basic app', function() { |
| 16 | + const args = ['ember-cli-typescript']; |
| 17 | + |
| 18 | + return emberNew() |
| 19 | + .then(() => emberGenerate(args)) |
| 20 | + .then(() => { |
| 21 | + const tsconfig = file('tsconfig.json'); |
| 22 | + expect(tsconfig).to.exist; |
| 23 | + |
| 24 | + const json = JSON.parse(tsconfig.content); |
| 25 | + expect(json.compilerOptions.paths).to.deep.equal({ |
| 26 | + 'my-app/tests/*': [ 'tests/*' ], |
| 27 | + 'my-app/*': [ 'app/*' ] |
| 28 | + }); |
| 29 | + }); |
| 30 | + }); |
| 31 | + |
| 32 | + it('in-repo addons', function() { |
| 33 | + const args = ['ember-cli-typescript']; |
| 34 | + |
| 35 | + return emberNew() |
| 36 | + .then(() => { |
| 37 | + const packagePath = path.resolve(process.cwd(), 'package.json'); |
| 38 | + const contents = JSON.parse(fs.readFileSync(packagePath, { encoding: 'utf8' })); |
| 39 | + contents['ember-addon'] = { |
| 40 | + paths: [ |
| 41 | + 'lib/my-addon-1', |
| 42 | + 'lib/my-addon-2' |
| 43 | + ] |
| 44 | + }; |
| 45 | + fs.writeFileSync(packagePath, JSON.stringify(contents, null, 2)); |
| 46 | + }) |
| 47 | + .then(() => emberGenerate(args)) |
| 48 | + .then(() => { |
| 49 | + const tsconfig = file('tsconfig.json'); |
| 50 | + expect(tsconfig).to.exist; |
| 51 | + |
| 52 | + const json = JSON.parse(tsconfig.content); |
| 53 | + expect(json.compilerOptions.paths).to.deep.equal({ |
| 54 | + 'my-app/tests/*': [ 'tests/*' ], |
| 55 | + 'my-app/*': [ |
| 56 | + 'app/*', |
| 57 | + 'lib/my-addon-1/app/*', |
| 58 | + 'lib/my-addon-2/app/*', |
| 59 | + ] |
| 60 | + }); |
| 61 | + }); |
| 62 | + }); |
| 63 | + |
| 64 | +}); |
0 commit comments