( type: Type, isError: boolean, throwSpecialError?: 'redirect' | 'http', )
| 59 | } |
| 60 | |
| 61 | function resolve( |
| 62 | type: Type, |
| 63 | isError: boolean, |
| 64 | throwSpecialError?: 'redirect' | 'http', |
| 65 | ): Parameters<Handle>[0]['resolve'] { |
| 66 | if (throwSpecialError === 'redirect') { |
| 67 | throw redirect(302, '/redirect'); |
| 68 | } |
| 69 | if (throwSpecialError === 'http') { |
| 70 | throw { status: 404, body: 'Not found' }; |
| 71 | } |
| 72 | |
| 73 | if (type === Type.Sync) { |
| 74 | return (..._args: unknown[]) => { |
| 75 | if (isError) { |
| 76 | throw new Error(type); |
| 77 | } |
| 78 | |
| 79 | return mockResponse; |
| 80 | }; |
| 81 | } |
| 82 | |
| 83 | return (..._args: unknown[]) => { |
| 84 | return new Promise((resolve, reject) => { |
| 85 | if (isError) { |
| 86 | reject(new Error(type)); |
| 87 | } else { |
| 88 | resolve(mockResponse); |
| 89 | } |
| 90 | }); |
| 91 | }; |
| 92 | } |
| 93 | |
| 94 | let client: NodeClient; |
| 95 |
no outgoing calls
no test coverage detected