@@ -5,6 +5,7 @@ const path = require('path');
55const helpers = require ( 'ember-cli-blueprint-test-helpers/helpers' ) ;
66const chaiHelpers = require ( 'ember-cli-blueprint-test-helpers/chai' ) ;
77const Blueprint = require ( 'ember-cli/lib/models/blueprint' ) ;
8+ const Project = require ( 'ember-cli/lib/models/project' ) ;
89
910const ects = require ( '../../blueprints/ember-cli-typescript' ) ;
1011
@@ -130,6 +131,108 @@ describe('Acceptance: ember-cli-typescript generator', function() {
130131 } ) ;
131132 } ) ;
132133
134+ describe ( 'module unification' , function ( ) {
135+ const originalIsMU = Project . prototype . isModuleUnification ;
136+
137+ beforeEach ( function ( ) {
138+ Project . prototype . isModuleUnification = ( ) => true ;
139+ } ) ;
140+
141+ afterEach ( function ( ) {
142+ Project . prototype . isModuleUnification = originalIsMU ;
143+ } ) ;
144+
145+ it ( 'basic app' , function ( ) {
146+ const args = [ 'ember-cli-typescript' ] ;
147+
148+ return helpers
149+ . emberNew ( )
150+ . then ( ( ) => helpers . emberGenerate ( args ) )
151+ . then ( ( ) => {
152+ const pkg = file ( 'package.json' ) ;
153+ expect ( pkg ) . to . exist ;
154+
155+ const pkgJson = JSON . parse ( pkg . content ) ;
156+ expect ( pkgJson . scripts . prepublishOnly ) . to . be . undefined ;
157+ expect ( pkgJson . scripts . postpublish ) . to . be . undefined ;
158+ expect ( pkgJson . devDependencies ) . to . include . all . keys ( 'ember-data' ) ;
159+ expect ( pkgJson . devDependencies ) . to . include . all . keys ( '@types/ember-data' ) ;
160+ expect ( pkgJson . devDependencies ) . to . include . all . keys ( 'ember-cli-qunit' ) ;
161+ expect ( pkgJson . devDependencies ) . to . include . all . keys ( '@types/ember-qunit' , '@types/qunit' ) ;
162+ expect ( pkgJson . devDependencies ) . to . not . have . any . keys ( '@types/ember-mocha' , '@types/mocha' ) ;
163+
164+ const tsconfig = file ( 'tsconfig.json' ) ;
165+ expect ( tsconfig ) . to . exist ;
166+
167+ const tsconfigJson = JSON . parse ( tsconfig . content ) ;
168+ expect ( tsconfigJson . compilerOptions . paths ) . to . deep . equal ( {
169+ 'my-app/tests/*' : [ 'tests/*' ] ,
170+ 'my-app/src/*' : [ 'src/*' ] ,
171+ '*' : [ 'types/*' ] ,
172+ } ) ;
173+
174+ expect ( tsconfigJson . compilerOptions . inlineSourceMap ) . to . equal ( true ) ;
175+ expect ( tsconfigJson . compilerOptions . inlineSources ) . to . equal ( true ) ;
176+
177+ expect ( tsconfigJson . include ) . to . deep . equal ( [ 'src/**/*' , 'tests/**/*' , 'types/**/*' ] ) ;
178+
179+ const projectTypes = file ( 'types/my-app/index.d.ts' ) ;
180+ expect ( projectTypes ) . to . exist ;
181+ expect ( projectTypes ) . to . include ( ects . APP_DECLARATIONS ) ;
182+
183+ const environmentTypes = file ( 'config/environment.d.ts' ) ;
184+ expect ( environmentTypes ) . to . exist ;
185+
186+ const emberDataCatchallTypes = file ( 'types/ember-data.d.ts' ) ;
187+ expect ( emberDataCatchallTypes ) . to . exist ;
188+ } ) ;
189+ } ) ;
190+
191+ it ( 'basic addon' , function ( ) {
192+ const args = [ 'ember-cli-typescript' ] ;
193+
194+ return helpers
195+ . emberNew ( { target : 'addon' } )
196+ . then ( ( ) => helpers . emberGenerate ( args ) )
197+ . then ( ( ) => {
198+ const pkg = file ( 'package.json' ) ;
199+ expect ( pkg ) . to . exist ;
200+
201+ const pkgJson = JSON . parse ( pkg . content ) ;
202+ expect ( pkgJson . scripts . prepublishOnly ) . to . equal ( 'ember ts:precompile' ) ;
203+ expect ( pkgJson . scripts . postpublish ) . to . equal ( 'ember ts:clean' ) ;
204+ expect ( pkgJson . devDependencies ) . to . not . have . any . keys ( 'ember-data' ) ;
205+ expect ( pkgJson . devDependencies ) . to . not . have . any . keys ( '@types/ember-data' ) ;
206+ expect ( pkgJson . devDependencies ) . to . include . all . keys ( 'ember-cli-qunit' ) ;
207+ expect ( pkgJson . devDependencies ) . to . include . all . keys ( '@types/ember-qunit' , '@types/qunit' ) ;
208+ expect ( pkgJson . devDependencies ) . to . not . have . any . keys ( '@types/ember-mocha' , '@types/mocha' ) ;
209+
210+ const tsconfig = file ( 'tsconfig.json' ) ;
211+ expect ( tsconfig ) . to . exist ;
212+
213+ const tsconfigJson = JSON . parse ( tsconfig . content ) ;
214+ expect ( tsconfigJson . compilerOptions . paths ) . to . deep . equal ( {
215+ 'dummy/tests/*' : [ 'tests/*' ] ,
216+ 'dummy/src/*' : [ 'tests/dummy/src/*' ] ,
217+ 'my-addon/src/*' : [ 'src/*' ] ,
218+ '*' : [ 'types/*' ] ,
219+ } ) ;
220+
221+ expect ( tsconfigJson . include ) . to . deep . equal ( [ 'src/**/*' , 'tests/**/*' , 'types/**/*' ] ) ;
222+
223+ const projectTypes = file ( 'types/dummy/index.d.ts' ) ;
224+ expect ( projectTypes ) . to . exist ;
225+ expect ( projectTypes ) . not . to . include ( ects . APP_DECLARATIONS ) ;
226+
227+ const environmentTypes = file ( 'tests/dummy/config/environment.d.ts' ) ;
228+ expect ( environmentTypes ) . to . exist ;
229+
230+ const emberDataCatchallTypes = file ( 'types/ember-data.d.ts' ) ;
231+ expect ( emberDataCatchallTypes ) . not . to . exist ;
232+ } ) ;
233+ } ) ;
234+ } ) ;
235+
133236 it ( 'in-repo addons' , function ( ) {
134237 const args = [ 'ember-cli-typescript' ] ;
135238
0 commit comments