11import assert from "assert" ;
2- import { HeadersInit } from "@mrbbot/node-fetch" ;
2+ import { HeadersInit , RequestInfo } from "@mrbbot/node-fetch" ;
33import anyTest , { Macro , TestInterface } from "ava" ;
44import {
55 Cache ,
@@ -34,7 +34,7 @@ const testResponse = new Response("value", {
3434
3535// Cache:* tests adapted from Cloudworker:
3636// https://github.com/dollarshaveclub/cloudworker/blob/master/lib/runtime/cache/__tests__/cache.test.js
37- const putMacro : Macro < [ string | Request ] , Context > = async ( t , req ) => {
37+ const putMacro : Macro < [ RequestInfo ] , Context > = async ( t , req ) => {
3838 const { storage, cache } = t . context ;
3939 await cache . put ( req , testResponse . clone ( ) ) ;
4040
@@ -54,6 +54,7 @@ const putMacro: Macro<[string | Request], Context> = async (t, req) => {
5454putMacro . title = ( providedTitle ) => `Cache: puts ${ providedTitle } ` ;
5555test ( "request" , putMacro , new Request ( "http://localhost:8787/test" ) ) ;
5656test ( "string request" , putMacro , "http://localhost:8787/test" ) ;
57+ test ( "url request" , putMacro , new URL ( "http://localhost:8787/test" ) ) ;
5758
5859test ( "Cache: only puts GET requests" , async ( t ) => {
5960 const { storage, cache } = t . context ;
@@ -69,7 +70,7 @@ test("Cache: only puts GET requests", async (t) => {
6970 ) ;
7071} ) ;
7172
72- const matchMacro : Macro < [ string | Request ] , Context > = async ( t , req ) => {
73+ const matchMacro : Macro < [ RequestInfo ] , Context > = async ( t , req ) => {
7374 const { cache } = t . context ;
7475 await cache . put (
7576 new Request ( "http://localhost:8787/test" ) ,
@@ -87,6 +88,7 @@ const matchMacro: Macro<[string | Request], Context> = async (t, req) => {
8788matchMacro . title = ( providedTitle ) => `Cache: matches ${ providedTitle } ` ;
8889test ( "request" , matchMacro , new Request ( "http://localhost:8787/test" ) ) ;
8990test ( "string request" , matchMacro , "http://localhost:8787/test" ) ;
91+ test ( "url request" , matchMacro , new URL ( "http://localhost:8787/test" ) ) ;
9092
9193test ( "Cache: only matches non-GET requests when ignoring method" , async ( t ) => {
9294 const { cache } = t . context ;
@@ -99,7 +101,7 @@ test("Cache: only matches non-GET requests when ignoring method", async (t) => {
99101 t . not ( await cache . match ( req , { ignoreMethod : true } ) , undefined ) ;
100102} ) ;
101103
102- const deleteMacro : Macro < [ string | Request ] , Context > = async ( t , req ) => {
104+ const deleteMacro : Macro < [ RequestInfo ] , Context > = async ( t , req ) => {
103105 const { storage, cache } = t . context ;
104106 await cache . put (
105107 new Request ( "http://localhost:8787/test" ) ,
@@ -113,6 +115,7 @@ const deleteMacro: Macro<[string | Request], Context> = async (t, req) => {
113115deleteMacro . title = ( providedTitle ) => `Cache: deletes ${ providedTitle } ` ;
114116test ( "request" , deleteMacro , new Request ( "http://localhost:8787/test" ) ) ;
115117test ( "string request" , deleteMacro , "http://localhost:8787/test" ) ;
118+ test ( "url request" , deleteMacro , new URL ( "http://localhost:8787/test" ) ) ;
116119
117120test ( "Cache: only deletes non-GET requests when ignoring method" , async ( t ) => {
118121 const { cache } = t . context ;
0 commit comments