(fixtureName, cb)
| 88 | } |
| 89 | |
| 90 | function uploadFixture(fixtureName, cb) { |
| 91 | server.once('request', (req, res) => { |
| 92 | const form = formidable({ |
| 93 | uploadDir: UPLOAD_DIR, |
| 94 | hashAlgorithm: 'sha1', |
| 95 | }); |
| 96 | form.parse(req); |
| 97 | |
| 98 | function callback(...args) { |
| 99 | const realCallback = cb; |
| 100 | // eslint-disable-next-line no-param-reassign |
| 101 | cb = function callbackFn() {}; |
| 102 | |
| 103 | realCallback(...args); |
| 104 | } |
| 105 | |
| 106 | const parts = []; |
| 107 | form |
| 108 | .on('error', callback) |
| 109 | .on('fileBegin', (name, value) => { |
| 110 | parts.push({ type: 'file', name, value }); |
| 111 | }) |
| 112 | .on('field', (name, value) => { |
| 113 | parts.push({ type: 'field', name, value }); |
| 114 | }) |
| 115 | .on('end', () => { |
| 116 | res.end(); |
| 117 | callback(null, parts); |
| 118 | }); |
| 119 | }); |
| 120 | |
| 121 | const socket = createConnection(PORT); |
| 122 | const fixturePath = join(FIXTURES_HTTP, fixtureName); |
| 123 | const file = createReadStream(fixturePath); |
| 124 | |
| 125 | file.pipe(socket, { end: false }); |
| 126 | |
| 127 | socket.on('data', () => { |
| 128 | socket.end(); |
| 129 | }); |
| 130 | } |
| 131 | }); |
no test coverage detected
searching dependent graphs…