1- import { http , HttpResponse } from "msw" ;
1+ import { http } from "msw/core/http " ;
22import { assert , expect , test , vi } from "vitest" ;
33import { server } from "../../vitest.setup.js" ;
44import { parsedJsonReplacer } from "../core/utils/index.js" ;
@@ -1299,10 +1299,8 @@ const init = {
12991299
13001300test ( "parse a Hydra documentation" , async ( ) => {
13011301 server . use (
1302- http . get ( "http://localhost" , ( ) => HttpResponse . json ( entrypoint , init ) ) ,
1303- http . get ( "http://localhost/docs.jsonld" , ( ) =>
1304- HttpResponse . json ( docs , init ) ,
1305- ) ,
1302+ http . get ( "http://localhost" , ( ) => Response . json ( entrypoint , init ) ) ,
1303+ http . get ( "http://localhost/docs.jsonld" , ( ) => Response . json ( docs , init ) ) ,
13061304 ) ;
13071305
13081306 const fetchSpy = vi . spyOn ( globalThis , "fetch" ) ;
@@ -1332,10 +1330,8 @@ function getHeaders(): Headers {
13321330
13331331test ( "parse a Hydra documentation using dynamic headers" , async ( ) => {
13341332 server . use (
1335- http . get ( "http://localhost" , ( ) => HttpResponse . json ( entrypoint , init ) ) ,
1336- http . get ( "http://localhost/docs.jsonld" , ( ) =>
1337- HttpResponse . json ( docs , init ) ,
1338- ) ,
1333+ http . get ( "http://localhost" , ( ) => Response . json ( entrypoint , init ) ) ,
1334+ http . get ( "http://localhost/docs.jsonld" , ( ) => Response . json ( docs , init ) ) ,
13391335 ) ;
13401336
13411337 const fetchSpy = vi . spyOn ( globalThis , "fetch" ) ;
@@ -1362,10 +1358,8 @@ test("parse a Hydra documentation using dynamic headers", async () => {
13621358
13631359test ( "parse a Hydra documentation (http://localhost/)" , async ( ) => {
13641360 server . use (
1365- http . get ( "http://localhost" , ( ) => HttpResponse . json ( entrypoint , init ) ) ,
1366- http . get ( "http://localhost/docs.jsonld" , ( ) =>
1367- HttpResponse . json ( docs , init ) ,
1368- ) ,
1361+ http . get ( "http://localhost" , ( ) => Response . json ( entrypoint , init ) ) ,
1362+ http . get ( "http://localhost/docs.jsonld" , ( ) => Response . json ( docs , init ) ) ,
13691363 ) ;
13701364
13711365 const data = await parseHydraDocumentation ( "http://localhost/" ) ;
@@ -1393,9 +1387,7 @@ test("parse a Hydra documentation without authorization", async () => {
13931387 } ;
13941388
13951389 server . use (
1396- http . get ( "http://localhost" , ( ) =>
1397- HttpResponse . json ( expectedResponse , init ) ,
1398- ) ,
1390+ http . get ( "http://localhost" , ( ) => Response . json ( expectedResponse , init ) ) ,
13991391 ) ;
14001392 const promise = parseHydraDocumentation ( "http://localhost" ) ;
14011393 await expect ( promise ) . rejects . toMatchObject ( {
@@ -1434,10 +1426,8 @@ test('Parse entrypoint without "@type" key', async () => {
14341426 } ;
14351427
14361428 server . use (
1437- http . get ( "http://localhost" , ( ) => HttpResponse . json ( entrypoint , init ) ) ,
1438- http . get ( "http://localhost/docs.jsonld" , ( ) =>
1439- HttpResponse . json ( docs , init ) ,
1440- ) ,
1429+ http . get ( "http://localhost" , ( ) => Response . json ( entrypoint , init ) ) ,
1430+ http . get ( "http://localhost/docs.jsonld" , ( ) => Response . json ( docs , init ) ) ,
14411431 ) ;
14421432
14431433 await expect ( parseHydraDocumentation ( "http://localhost/" ) ) . rejects . toThrow (
@@ -1482,10 +1472,8 @@ test('Parse entrypoint class without "supportedClass" key', async () => {
14821472 } ;
14831473
14841474 server . use (
1485- http . get ( "http://localhost" , ( ) => HttpResponse . json ( entrypoint , init ) ) ,
1486- http . get ( "http://localhost/docs.jsonld" , ( ) =>
1487- HttpResponse . json ( docs , init ) ,
1488- ) ,
1475+ http . get ( "http://localhost" , ( ) => Response . json ( entrypoint , init ) ) ,
1476+ http . get ( "http://localhost/docs.jsonld" , ( ) => Response . json ( docs , init ) ) ,
14891477 ) ;
14901478
14911479 await expect ( parseHydraDocumentation ( "http://localhost/" ) ) . rejects . toThrow (
@@ -1546,10 +1534,8 @@ test('Parse entrypoint class without "supportedProperty" key', async () => {
15461534 'The entrypoint definition has no "http://www.w3.org/ns/hydra/core#supportedProperty" key or it is not an array.' ;
15471535
15481536 server . use (
1549- http . get ( "http://localhost" , ( ) => HttpResponse . json ( entrypoint , init ) ) ,
1550- http . get ( "http://localhost/docs.jsonld" , ( ) =>
1551- HttpResponse . json ( docs , init ) ,
1552- ) ,
1537+ http . get ( "http://localhost" , ( ) => Response . json ( entrypoint , init ) ) ,
1538+ http . get ( "http://localhost/docs.jsonld" , ( ) => Response . json ( docs , init ) ) ,
15531539 ) ;
15541540
15551541 await expect ( parseHydraDocumentation ( "http://localhost/" ) ) . rejects . toThrow (
@@ -1561,11 +1547,8 @@ test("Invalid docs JSON", async () => {
15611547 const docs = `{foo,}` ;
15621548
15631549 server . use (
1564- http . get ( "http://localhost" , ( ) => HttpResponse . json ( entrypoint , init ) ) ,
1565- http . get (
1566- "http://localhost/docs.jsonld" ,
1567- ( ) => new HttpResponse ( docs , init ) ,
1568- ) ,
1550+ http . get ( "http://localhost" , ( ) => Response . json ( entrypoint , init ) ) ,
1551+ http . get ( "http://localhost/docs.jsonld" , ( ) => new Response ( docs , init ) ) ,
15691552 ) ;
15701553
15711554 const promise = parseHydraDocumentation ( "http://localhost/" ) ;
@@ -1578,7 +1561,7 @@ test("Invalid docs JSON", async () => {
15781561test ( "Invalid entrypoint JSON" , async ( ) => {
15791562 const entrypoint = `{foo,}` ;
15801563 server . use (
1581- http . get ( "http://localhost" , ( ) => new HttpResponse ( entrypoint , init ) ) ,
1564+ http . get ( "http://localhost" , ( ) => new Response ( entrypoint , init ) ) ,
15821565 ) ;
15831566
15841567 const promise = parseHydraDocumentation ( "http://localhost/" ) ;
@@ -1591,12 +1574,10 @@ test("Invalid entrypoint JSON", async () => {
15911574test ( "Resource parameters can be retrieved" , async ( ) => {
15921575 const fetchSpy = vi . spyOn ( globalThis , "fetch" ) ;
15931576 server . use (
1594- http . get ( "http://localhost" , ( ) => HttpResponse . json ( entrypoint , init ) ) ,
1595- http . get ( "http://localhost/docs.jsonld" , ( ) =>
1596- HttpResponse . json ( docs , init ) ,
1597- ) ,
1577+ http . get ( "http://localhost" , ( ) => Response . json ( entrypoint , init ) ) ,
1578+ http . get ( "http://localhost/docs.jsonld" , ( ) => Response . json ( docs , init ) ) ,
15981579 http . get ( "http://localhost/books" , ( ) =>
1599- HttpResponse . json ( resourceCollectionWithParameters , init ) ,
1580+ Response . json ( resourceCollectionWithParameters , init ) ,
16001581 ) ,
16011582 ) ;
16021583
0 commit comments