Jobley / website · jobley.ai / test / retired-native.test.mjs
| 1 | import { test } from 'node:test'; |
| 2 | import assert from 'node:assert/strict'; |
| 3 | import { onRequest } from '../functions/_middleware.js'; |
| 4 | |
| 5 | test('installer and appcast requests are gone even with storage bound', async () => { |
| 6 | for (const path of ['/downloads/Jobley-0.1.1.dmg', '/downloads/Jobley%2Dlegacy.zip', '/appcast.xml', '/appcast-legacy.xml']) { |
| 7 | for (const method of ['GET', 'HEAD']) { |
| 8 | const response = await onRequest({ |
| 9 | request: new Request('https://jobley.ai' + path, { method, headers: { Range: 'bytes=0-8' } }), |
| 10 | env: { DOWNLOADS: { get() { throw new Error('Storage must not be accessed'); } } }, |
| 11 | next() { throw new Error('Must not fall through'); }, |
| 12 | }); |
| 13 | assert.equal(response.status, 410, path); |
| 14 | assert.equal(response.headers.get('cache-control'), 'no-store'); |
| 15 | assert.equal(response.headers.get('content-type'), 'text/plain; charset=utf-8'); |
| 16 | if (method === 'HEAD') assert.equal(await response.text(), ''); |
| 17 | } |
| 18 | } |
| 19 | }); |