@@ -115,4 +115,37 @@ describe('Acceptance: ts:precompile command', function () {
115115 expect ( declaration . content . trim ( ) ) . to . equal ( `export declare const testString: string;` ) ;
116116 } ) ;
117117 } ) ;
118+
119+ it ( 'generates .d.ts files for components when addon and moduleName do not match' , function ( ) {
120+ fs . ensureDirSync ( 'addon/components' ) ;
121+ fs . writeFileSync (
122+ 'addon/components/my-component.ts' ,
123+ `export const testString: string = 'hello';`
124+ ) ;
125+ fs . ensureDirSync ( 'addon-test-support' ) ;
126+ fs . writeFileSync (
127+ 'addon-test-support/test-file.ts' ,
128+ `export const anotherTestString: string = 'hello';`
129+ ) ;
130+ fs . writeFileSync (
131+ 'index.js' ,
132+ `module.exports = { name: '@foo/my-addon', moduleName() { return 'my-addon'; } };`
133+ ) ;
134+
135+ const pkg = fs . readJSONSync ( 'package.json' ) ;
136+ pkg . name = '@foo/my-addon' ; // addon `moduleName()` is `my-addon`
137+ fs . writeJSONSync ( 'package.json' , pkg ) ;
138+
139+ return ember ( [ 'ts:precompile' ] ) . then ( ( ) => {
140+ const componentDecl = file ( 'components/my-component.d.ts' ) ;
141+ expect ( componentDecl ) . to . exist ;
142+ expect ( componentDecl . content . trim ( ) ) . to . equal ( `export declare const testString: string;` ) ;
143+
144+ const testSupportDecl = file ( 'test-support/test-file.d.ts' ) ;
145+ expect ( testSupportDecl ) . to . exist ;
146+ expect ( testSupportDecl . content . trim ( ) ) . to . equal (
147+ `export declare const anotherTestString: string;`
148+ ) ;
149+ } ) ;
150+ } ) ;
118151} ) ;
0 commit comments