| 41 | } |
| 42 | |
| 43 | class MockRequest { |
| 44 | constructor(url, init = {}) { |
| 45 | this.url = url; |
| 46 | this.method = init.method || 'GET'; |
| 47 | this.headers = init.headers instanceof MockHeaders ? init.headers : new MockHeaders(init.headers || {}); |
| 48 | this.body = init.body; |
| 49 | } |
| 50 | |
| 51 | async arrayBuffer() { |
| 52 | const text = typeof this.body === 'string' ? this.body : JSON.stringify(this.body || ''); |
| 53 | return new TextEncoder().encode(text).buffer; |
| 54 | } |
| 55 | |
| 56 | async json() { |
| 57 | const text = typeof this.body === 'string' ? this.body : JSON.stringify(this.body || ''); |
| 58 | return JSON.parse(text); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | class MockResponse { |
| 63 | constructor(body = '', init = {}) { |
nothing calls this directly
no outgoing calls
no test coverage detected