fix(ext/cache): illegal constructor (#16205)

This commit is contained in:
Marcos Casagrande 2022-10-16 19:33:17 +02:00 committed by GitHub
parent 07213dec94
commit 5252ff5dbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 9 deletions

View file

@ -4,6 +4,7 @@ import {
assertEquals,
assertFalse,
assertRejects,
assertThrows,
} from "./test_util.ts";
Deno.test(async function cacheStorage() {
@ -95,6 +96,13 @@ Deno.test(async function cacheApi() {
assertFalse(await caches.has(cacheName));
});
Deno.test(function cacheIllegalConstructor() {
// @ts-expect-error illegal constructor
assertThrows(() => new Cache(), TypeError, "Illegal constructor");
// @ts-expect-error illegal constructor
assertThrows(() => new Cache("foo", "bar"), TypeError, "Illegal constructor");
});
Deno.test(async function cachePutReaderLock() {
const cacheName = "cache-v1";
const cache = await caches.open(cacheName);