@@ -4,16 +4,19 @@ const mm = require('mm');
44const request = require ( 'supertest' ) ;
55const assert = require ( 'assert' ) ;
66const utils = require ( './utils' ) ;
7+ const loaderUtil = require ( '../lib/utils' ) ;
78
89describe ( 'test/egg-ts.test.js' , ( ) => {
910 let app ;
1011
1112 beforeEach ( ( ) => {
1213 require . extensions [ '.ts' ] = require . extensions [ '.js' ] ;
14+ loaderUtil . extensions . push ( '.ts' ) ;
1315 } ) ;
1416
1517 afterEach ( ( ) => {
1618 mm . restore ( ) ;
19+ loaderUtil . extensions . splice ( loaderUtil . extensions . indexOf ( '.ts' ) , 1 ) ;
1720 delete require . extensions [ '.ts' ] ;
1821 } ) ;
1922
@@ -99,10 +102,6 @@ describe('test/egg-ts.test.js', () => {
99102 } ) ;
100103 } ) ;
101104
102- it ( 'should support load ts file' , async ( ) => {
103-
104- } ) ;
105-
106105 it ( 'should not load d.ts files while typescript was true' , async ( ) => {
107106 mm ( process . env , 'EGG_TYPESCRIPT' , 'true' ) ;
108107 app = utils . createApp ( 'egg-ts-js' ) ;
@@ -133,12 +132,9 @@ describe('test/egg-ts.test.js', () => {
133132
134133 it ( 'should not load ts files while EGG_TYPESCRIPT was true but no extensions' , async ( ) => {
135134 mm ( process . env , 'EGG_TYPESCRIPT' , 'true' ) ;
136- delete require . extensions [ '.ts' ] ;
135+ mm ( loaderUtil , ' extensions' , [ '.js' , '.json' ] ) ;
137136 app = utils . createApp ( 'egg-ts-js' ) ;
138-
139- app . loader . loadApplicationExtend ( ) ;
140137 app . loader . loadService ( ) ;
141- assert ( ! app . appExtend ) ;
142138 assert ( app . serviceClasses . lord ) ;
143139 assert ( ! app . serviceClasses . test ) ;
144140 } ) ;
0 commit comments