@@ -2,33 +2,27 @@ import ts, { factory as f } from "typescript";
22import { getVariablesType } from "./getVariablesType" ;
33
44describe ( "getVariableType" , ( ) => {
5- it ( "should return the fetcherOption type if no types are provided" , ( ) => {
5+ it ( "should return void if no types are provided" , ( ) => {
66 const variablesType = getVariablesType ( {
7- withContextType : true ,
87 requestBodyType : undefinedType ,
98 headersType : undefinedType ,
109 pathParamsType : undefinedType ,
1110 queryParamsType : undefinedType ,
12- contextTypeName : "MyContext" ,
1311 headersOptional : false ,
1412 pathParamsOptional : false ,
1513 queryParamsOptional : false ,
1614 requestBodyOptional : false ,
1715 } ) ;
1816
19- expect ( print ( variablesType ) ) . toMatchInlineSnapshot (
20- `"MyContext[\\"fetcherOptions\\"]"`
21- ) ;
17+ expect ( print ( variablesType ) ) . toMatchInlineSnapshot ( `"void"` ) ;
2218 } ) ;
2319
2420 it ( "should have requestBody type declared" , ( ) => {
2521 const variablesType = getVariablesType ( {
26- withContextType : true ,
2722 requestBodyType : f . createKeywordTypeNode ( ts . SyntaxKind . StringKeyword ) ,
2823 headersType : undefinedType ,
2924 pathParamsType : undefinedType ,
3025 queryParamsType : undefinedType ,
31- contextTypeName : "MyContext" ,
3226 headersOptional : false ,
3327 pathParamsOptional : false ,
3428 queryParamsOptional : false ,
@@ -38,18 +32,16 @@ describe("getVariableType", () => {
3832 expect ( print ( variablesType ) ) . toMatchInlineSnapshot ( `
3933 "{
4034 body: string;
41- } & MyContext[\\"fetcherOptions\\"] "
35+ }"
4236 ` ) ;
4337 } ) ;
4438
4539 it ( "should have headers type declared" , ( ) => {
4640 const variablesType = getVariablesType ( {
47- withContextType : true ,
4841 requestBodyType : undefinedType ,
4942 headersType : createType ( "Headers" , "Foo" ) ,
5043 pathParamsType : undefinedType ,
5144 queryParamsType : undefinedType ,
52- contextTypeName : "MyContext" ,
5345 headersOptional : false ,
5446 pathParamsOptional : false ,
5547 queryParamsOptional : false ,
@@ -59,18 +51,16 @@ describe("getVariableType", () => {
5951 expect ( print ( variablesType ) ) . toMatchInlineSnapshot ( `
6052 "{
6153 headers: Headers.Foo;
62- } & MyContext[\\"fetcherOptions\\"] "
54+ }"
6355 ` ) ;
6456 } ) ;
6557
6658 it ( "should have pathParams type declared" , ( ) => {
6759 const variablesType = getVariablesType ( {
68- withContextType : true ,
6960 requestBodyType : undefinedType ,
7061 headersType : undefinedType ,
7162 pathParamsType : f . createKeywordTypeNode ( ts . SyntaxKind . NumberKeyword ) ,
7263 queryParamsType : undefinedType ,
73- contextTypeName : "MyContext" ,
7464 headersOptional : false ,
7565 pathParamsOptional : false ,
7666 queryParamsOptional : false ,
@@ -80,18 +70,16 @@ describe("getVariableType", () => {
8070 expect ( print ( variablesType ) ) . toMatchInlineSnapshot ( `
8171 "{
8272 pathParams: number;
83- } & MyContext[\\"fetcherOptions\\"] "
73+ }"
8474 ` ) ;
8575 } ) ;
8676
8777 it ( "should have queryParams type declared" , ( ) => {
8878 const variablesType = getVariablesType ( {
89- withContextType : true ,
9079 requestBodyType : undefinedType ,
9180 headersType : undefinedType ,
9281 pathParamsType : undefinedType ,
9382 queryParamsType : createType ( "QueryParams" , "Foo" ) ,
94- contextTypeName : "MyContext" ,
9583 headersOptional : false ,
9684 pathParamsOptional : false ,
9785 queryParamsOptional : false ,
@@ -101,37 +89,31 @@ describe("getVariableType", () => {
10189 expect ( print ( variablesType ) ) . toMatchInlineSnapshot ( `
10290 "{
10391 queryParams: QueryParams.Foo;
104- } & MyContext[\\"fetcherOptions\\"] "
92+ }"
10593 ` ) ;
10694 } ) ;
10795
10896 it ( "should ignore empty type" , ( ) => {
10997 const variablesType = getVariablesType ( {
110- withContextType : true ,
11198 requestBodyType : undefinedType ,
11299 headersType : undefinedType ,
113100 pathParamsType : undefinedType ,
114101 queryParamsType : f . createTypeLiteralNode ( [ ] ) , // = {}
115- contextTypeName : "MyContext" ,
116102 headersOptional : false ,
117103 pathParamsOptional : false ,
118104 queryParamsOptional : false ,
119105 requestBodyOptional : false ,
120106 } ) ;
121107
122- expect ( print ( variablesType ) ) . toMatchInlineSnapshot (
123- `"MyContext[\\"fetcherOptions\\"]"`
124- ) ;
108+ expect ( print ( variablesType ) ) . toMatchInlineSnapshot ( `"void"` ) ;
125109 } ) ;
126110
127111 it ( "should combine types" , ( ) => {
128112 const variablesType = getVariablesType ( {
129- withContextType : true ,
130113 requestBodyType : createType ( "RequestBody" , "Pet" ) ,
131114 headersType : createType ( "Headers" , "Pet" ) ,
132115 pathParamsType : createType ( "PathParams" , "Pet" ) ,
133116 queryParamsType : createType ( "QueryParams" , "Pet" ) ,
134- contextTypeName : "MyContext" ,
135117 headersOptional : false ,
136118 pathParamsOptional : false ,
137119 queryParamsOptional : false ,
@@ -144,18 +126,16 @@ describe("getVariableType", () => {
144126 headers: Headers.Pet;
145127 pathParams: PathParams.Pet;
146128 queryParams: QueryParams.Pet;
147- } & MyContext[\\"fetcherOptions\\"] "
129+ }"
148130 ` ) ;
149131 } ) ;
150132
151133 it ( "should mark types as optional" , ( ) => {
152134 const variablesType = getVariablesType ( {
153- withContextType : true ,
154135 requestBodyType : createType ( "RequestBody" , "Pet" ) ,
155136 headersType : createType ( "Headers" , "Pet" ) ,
156137 pathParamsType : createType ( "PathParams" , "Pet" ) ,
157138 queryParamsType : createType ( "QueryParams" , "Pet" ) ,
158- contextTypeName : "MyContext" ,
159139 headersOptional : true ,
160140 pathParamsOptional : true ,
161141 queryParamsOptional : true ,
@@ -168,7 +148,7 @@ describe("getVariableType", () => {
168148 headers?: Headers.Pet;
169149 pathParams?: PathParams.Pet;
170150 queryParams?: QueryParams.Pet;
171- } & MyContext[\\"fetcherOptions\\"] "
151+ }"
172152 ` ) ;
173153 } ) ;
174154} ) ;
0 commit comments