From cdd9405f97da0dfe4ef5ed3917e9378130a81516 Mon Sep 17 00:00:00 2001 From: AdityaAtulTewari Date: Wed, 24 Jul 2024 09:44:25 -0500 Subject: [PATCH] Added test functionality to compare against --- src/workerd/api/http-test.js | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/workerd/api/http-test.js b/src/workerd/api/http-test.js index e77dd7c19c2..548a869b233 100644 --- a/src/workerd/api/http-test.js +++ b/src/workerd/api/http-test.js @@ -205,3 +205,45 @@ export const inspect = { await messagePromise; } }; + +export const cacheMode = { + async test() { + assert.strictEqual("cache" in Request.prototype, false); + { + const req = new Request('https://example.org', { }); + assert.strictEqual(req.cache, undefined); + } + { + assert.throws(() => { + new Request('https://example.org', { cache: 'no-store' }); + }, { + name: 'Error', + message: "The 'cache' field on 'RequestInitializerDict' is not implemented.", + }); + } + { + assert.throws(() => { + new Request('https://example.org', { cache: 'no-cache' }); + }, { + name: 'Error', + message: "The 'cache' field on 'RequestInitializerDict' is not implemented.", + }); + } + { + assert.throws(() => { + new Request('https://example.org', { cache: 'unsupported' }); + }, { + name: 'Error', + message: "The 'cache' field on 'RequestInitializerDict' is not implemented.", + }); + } + { + await assert.rejects((async () => { + await fetch('http://example.org', { cache: 'no-transform' }); + })(), { + name: 'Error', + message: "The 'cache' field on 'RequestInitializerDict' is not implemented.", + }); + } + } +}