(fileBufferMap: {
[filename: string]: string|Float32Array|Int32Array|ArrayBuffer|Uint8Array|
Uint16Array
})
| 64 | describe('nodeHTTPRequest-load', () => { |
| 65 | let requestInits: RequestInit[]; |
| 66 | const setupFakeWeightFiles = (fileBufferMap: { |
| 67 | [filename: string]: string|Float32Array|Int32Array|ArrayBuffer|Uint8Array| |
| 68 | Uint16Array |
| 69 | }) => { |
| 70 | spyOn(tf.env().platform, 'fetch') |
| 71 | .and.callFake((path: string, init: RequestInit) => { |
| 72 | return new Promise((resolve, reject) => { |
| 73 | let contentType = ''; |
| 74 | if (path.endsWith('model.json')) { |
| 75 | contentType = JSON_TYPE; |
| 76 | } else if ( |
| 77 | path.endsWith('weightfile0') || path.endsWith('weightfile1')) { |
| 78 | contentType = OCTET_STREAM_TYPE; |
| 79 | } else { |
| 80 | reject(new Error(`Invalid path: ${path}`)); |
| 81 | } |
| 82 | requestInits.push(init); |
| 83 | resolve(new fetch.Response( |
| 84 | fileBufferMap[path], |
| 85 | {'headers': {'Content-Type': contentType}})); |
| 86 | }); |
| 87 | }); |
| 88 | }; |
| 89 | |
| 90 | beforeEach(() => { |
| 91 | requestInits = []; |
no test coverage detected
searching dependent graphs…