| 158 | } |
| 159 | |
| 160 | export async function assertCanReadWriteCache() { |
| 161 | const entry = './test/fixtures/worker.js'; |
| 162 | const code = ` |
| 163 | addEventListener('fetch', async e => { |
| 164 | await caches.default.put('/', new Response(undefined, { status: 201, statusText: 'no content' })); |
| 165 | const response = await caches.default.match('/'); |
| 166 | e.respondWith(response); |
| 167 | });`; |
| 168 | await fs.outputFile(entry, code); |
| 169 | const command = new RunCommand({ |
| 170 | entry, |
| 171 | port, |
| 172 | inspect: false, |
| 173 | watch: false, |
| 174 | check: false, |
| 175 | kv: [] |
| 176 | }); |
| 177 | await command.execute(); |
| 178 | const response = await fetch('http://localhost:7000'); |
| 179 | assert.equal(response.status, 201); |
| 180 | assert.equal(response.statusText, 'no content'); |
| 181 | command.dispose(); |
| 182 | } |
| 183 | |
| 184 | export async function assertCanServeStaticSite() { |
| 185 | const entry = './test/fixtures/worker.js'; |