@@ -301,6 +301,32 @@ describe('Blueprint: route', function () {
301
301
} ) ;
302
302
} ) ;
303
303
} ) ;
304
+
305
+ it ( 'using a `router.ts` file' , async function ( ) {
306
+ fs . moveSync ( 'app/router.js' , 'app/router.ts' ) ;
307
+
308
+ await emberGenerate ( [ 'route' , 'foo' ] ) ;
309
+ expect ( file ( 'app/router.ts' ) ) . to . contain ( "this.route('foo')" ) ;
310
+
311
+ await emberDestroy ( [ 'route' , 'foo' ] ) ;
312
+ expect ( file ( 'app/router.ts' ) ) . to . not . contain ( "this.route('foo')" ) ;
313
+ } ) ;
314
+
315
+ it ( 'throws a helpful error if a router file could not be found' , async function ( ) {
316
+ fs . removeSync ( 'app/router.js' ) ;
317
+
318
+ await expect ( emberGenerate ( [ 'route' , 'foo' ] ) ) . to . be . rejectedWith (
319
+ 'Could not find a router file. Please make sure your project has a `router.js` or `router.ts` file.'
320
+ ) ;
321
+ } ) ;
322
+
323
+ it ( 'throws a helpful error if both a `router.ts` and `router.js` file are found' , async function ( ) {
324
+ fs . copySync ( 'app/router.js' , 'app/router.ts' ) ;
325
+
326
+ await expect ( emberGenerate ( [ 'route' , 'foo' ] ) ) . to . be . rejectedWith (
327
+ 'Found both a `router.js` and `router.ts` file. Please make sure your project only has one or the other.'
328
+ ) ;
329
+ } ) ;
304
330
} ) ;
305
331
306
332
describe ( 'in addon - octane' , function ( ) {
@@ -514,6 +540,32 @@ describe('Blueprint: route', function () {
514
540
} ) ;
515
541
} ) ;
516
542
} ) ;
543
+
544
+ it ( 'using a `router.ts` file' , async function ( ) {
545
+ fs . moveSync ( 'tests/dummy/app/router.js' , 'tests/dummy/app/router.ts' ) ;
546
+
547
+ await emberGenerate ( [ 'route' , 'foo' , '--dummy' ] ) ;
548
+ expect ( file ( 'tests/dummy/app/router.ts' ) ) . to . contain ( "this.route('foo')" ) ;
549
+
550
+ await emberDestroy ( [ 'route' , 'foo' , '--dummy' ] ) ;
551
+ expect ( file ( 'tests/dummy/app/router.ts' ) ) . to . not . contain ( "this.route('foo')" ) ;
552
+ } ) ;
553
+
554
+ it ( 'throws a helpful error if a router file could not be found' , async function ( ) {
555
+ fs . removeSync ( 'tests/dummy/app/router.js' ) ;
556
+
557
+ await expect ( emberGenerate ( [ 'route' , 'foo' , '--dummy' ] ) ) . to . be . rejectedWith (
558
+ 'Could not find a router file. Please make sure your project has a `router.js` or `router.ts` file.'
559
+ ) ;
560
+ } ) ;
561
+
562
+ it ( 'throws a helpful error if both a `router.ts` and `router.js` file are found' , async function ( ) {
563
+ fs . copySync ( 'tests/dummy/app/router.js' , 'tests/dummy/app/router.ts' ) ;
564
+
565
+ await expect ( emberGenerate ( [ 'route' , 'foo' , '--dummy' ] ) ) . to . be . rejectedWith (
566
+ 'Found both a `router.js` and `router.ts` file. Please make sure your project only has one or the other.'
567
+ ) ;
568
+ } ) ;
517
569
} ) ;
518
570
519
571
describe ( 'in in-repo-addon' , function ( ) {
0 commit comments