From 09b02cdab7df9c978809663bfc40010493b8a112 Mon Sep 17 00:00:00 2001 From: AdityaAtulTewari Date: Wed, 24 Jul 2024 10:53:57 -0500 Subject: [PATCH] Added test functionality to compare against (#2433) --- 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.", + }); + } + } +}