@@ -35,6 +35,10 @@ describe('createSvelteModuleLoader', () => {
3535 } ;
3636 }
3737
38+ function lastCall ( stub : sinon . SinonStub < any [ ] , any > ) {
39+ return stub . getCall ( stub . getCalls ( ) . length - 1 ) ;
40+ }
41+
3842 it ( 'uses tsSys for normal files' , async ( ) => {
3943 const resolvedModule : ts . ResolvedModuleFull = {
4044 extension : ts . Extension . Ts ,
@@ -47,7 +51,7 @@ describe('createSvelteModuleLoader', () => {
4751 ) ;
4852
4953 assert . deepStrictEqual ( result , [ resolvedModule ] ) ;
50- assert . deepStrictEqual ( resolveStub . getCall ( 0 ) . args , [
54+ assert . deepStrictEqual ( lastCall ( resolveStub ) . args , [
5155 './normal.ts' ,
5256 'C:/somerepo/somefile.svelte' ,
5357 compilerOptions ,
@@ -67,14 +71,34 @@ describe('createSvelteModuleLoader', () => {
6771 ) ;
6872
6973 assert . deepStrictEqual ( result , [ resolvedModule ] ) ;
70- assert . deepStrictEqual ( resolveStub . getCall ( 0 ) . args , [
74+ assert . deepStrictEqual ( lastCall ( resolveStub ) . args , [
7175 '/@/normal' ,
7276 'C:/somerepo/somefile.svelte' ,
7377 compilerOptions ,
7478 ts . sys
7579 ] ) ;
7680 } ) ;
7781
82+ it ( 'uses tsSys for svelte.d.ts files' , async ( ) => {
83+ const resolvedModule : ts . ResolvedModuleFull = {
84+ extension : ts . Extension . Dts ,
85+ resolvedFileName : 'filename.d.ts'
86+ } ;
87+ const { resolveStub, moduleResolver, compilerOptions } = setup ( resolvedModule ) ;
88+ const result = moduleResolver . resolveModuleNames (
89+ [ './normal.ts' ] ,
90+ 'C:/somerepo/somefile.svelte'
91+ ) ;
92+
93+ assert . deepStrictEqual ( result , [ resolvedModule ] ) ;
94+ assert . deepStrictEqual ( lastCall ( resolveStub ) . args , [
95+ './normal.ts' ,
96+ 'C:/somerepo/somefile.svelte' ,
97+ compilerOptions ,
98+ ts . sys
99+ ] ) ;
100+ } ) ;
101+
78102 it ( 'uses svelte module loader for virtual svelte files' , async ( ) => {
79103 const resolvedModule : ts . ResolvedModuleFull = {
80104 extension : ts . Extension . Ts ,
@@ -98,13 +122,13 @@ describe('createSvelteModuleLoader', () => {
98122 resolvedFileName : 'filename.svelte'
99123 }
100124 ] ) ;
101- assert . deepStrictEqual ( resolveStub . getCall ( 0 ) . args , [
125+ assert . deepStrictEqual ( lastCall ( resolveStub ) . args , [
102126 './svelte.svelte' ,
103127 'C:/somerepo/somefile.svelte' ,
104128 compilerOptions ,
105129 svelteSys
106130 ] ) ;
107- assert . deepStrictEqual ( getSvelteSnapshotStub . getCall ( 0 ) . args , [ 'filename.svelte' ] ) ;
131+ assert . deepStrictEqual ( lastCall ( getSvelteSnapshotStub ) . args , [ 'filename.svelte' ] ) ;
108132 } ) ;
109133
110134 it ( 'uses svelte module loader for virtual svelte files with TS path aliases' , async ( ) => {
@@ -130,13 +154,13 @@ describe('createSvelteModuleLoader', () => {
130154 resolvedFileName : 'filename.svelte'
131155 }
132156 ] ) ;
133- assert . deepStrictEqual ( resolveStub . getCall ( 0 ) . args , [
157+ assert . deepStrictEqual ( lastCall ( resolveStub ) . args , [
134158 '/@/svelte.svelte' ,
135159 'C:/somerepo/somefile.svelte' ,
136160 compilerOptions ,
137161 svelteSys
138162 ] ) ;
139- assert . deepStrictEqual ( getSvelteSnapshotStub . getCall ( 0 ) . args , [ 'filename.svelte' ] ) ;
163+ assert . deepStrictEqual ( lastCall ( getSvelteSnapshotStub ) . args , [ 'filename.svelte' ] ) ;
140164 } ) ;
141165
142166 it ( 'uses cache if module was already resolved before' , async ( ) => {
0 commit comments