1
- import { http , HttpResponse } from "msw" ;
1
+ import { http } from "msw/core/http " ;
2
2
import { assert , expect , test , vi } from "vitest" ;
3
3
import { server } from "../../vitest.setup.js" ;
4
4
import { parsedJsonReplacer } from "../core/utils/index.js" ;
@@ -1299,10 +1299,8 @@ const init = {
1299
1299
1300
1300
test ( "parse a Hydra documentation" , async ( ) => {
1301
1301
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 ) ) ,
1306
1304
) ;
1307
1305
1308
1306
const fetchSpy = vi . spyOn ( globalThis , "fetch" ) ;
@@ -1332,10 +1330,8 @@ function getHeaders(): Headers {
1332
1330
1333
1331
test ( "parse a Hydra documentation using dynamic headers" , async ( ) => {
1334
1332
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 ) ) ,
1339
1335
) ;
1340
1336
1341
1337
const fetchSpy = vi . spyOn ( globalThis , "fetch" ) ;
@@ -1362,10 +1358,8 @@ test("parse a Hydra documentation using dynamic headers", async () => {
1362
1358
1363
1359
test ( "parse a Hydra documentation (http://localhost/)" , async ( ) => {
1364
1360
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 ) ) ,
1369
1363
) ;
1370
1364
1371
1365
const data = await parseHydraDocumentation ( "http://localhost/" ) ;
@@ -1393,9 +1387,7 @@ test("parse a Hydra documentation without authorization", async () => {
1393
1387
} ;
1394
1388
1395
1389
server . use (
1396
- http . get ( "http://localhost" , ( ) =>
1397
- HttpResponse . json ( expectedResponse , init ) ,
1398
- ) ,
1390
+ http . get ( "http://localhost" , ( ) => Response . json ( expectedResponse , init ) ) ,
1399
1391
) ;
1400
1392
const promise = parseHydraDocumentation ( "http://localhost" ) ;
1401
1393
await expect ( promise ) . rejects . toMatchObject ( {
@@ -1434,10 +1426,8 @@ test('Parse entrypoint without "@type" key', async () => {
1434
1426
} ;
1435
1427
1436
1428
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 ) ) ,
1441
1431
) ;
1442
1432
1443
1433
await expect ( parseHydraDocumentation ( "http://localhost/" ) ) . rejects . toThrow (
@@ -1482,10 +1472,8 @@ test('Parse entrypoint class without "supportedClass" key', async () => {
1482
1472
} ;
1483
1473
1484
1474
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 ) ) ,
1489
1477
) ;
1490
1478
1491
1479
await expect ( parseHydraDocumentation ( "http://localhost/" ) ) . rejects . toThrow (
@@ -1546,10 +1534,8 @@ test('Parse entrypoint class without "supportedProperty" key', async () => {
1546
1534
'The entrypoint definition has no "http://www.w3.org/ns/hydra/core#supportedProperty" key or it is not an array.' ;
1547
1535
1548
1536
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 ) ) ,
1553
1539
) ;
1554
1540
1555
1541
await expect ( parseHydraDocumentation ( "http://localhost/" ) ) . rejects . toThrow (
@@ -1561,11 +1547,8 @@ test("Invalid docs JSON", async () => {
1561
1547
const docs = `{foo,}` ;
1562
1548
1563
1549
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 ) ) ,
1569
1552
) ;
1570
1553
1571
1554
const promise = parseHydraDocumentation ( "http://localhost/" ) ;
@@ -1578,7 +1561,7 @@ test("Invalid docs JSON", async () => {
1578
1561
test ( "Invalid entrypoint JSON" , async ( ) => {
1579
1562
const entrypoint = `{foo,}` ;
1580
1563
server . use (
1581
- http . get ( "http://localhost" , ( ) => new HttpResponse ( entrypoint , init ) ) ,
1564
+ http . get ( "http://localhost" , ( ) => new Response ( entrypoint , init ) ) ,
1582
1565
) ;
1583
1566
1584
1567
const promise = parseHydraDocumentation ( "http://localhost/" ) ;
@@ -1591,12 +1574,10 @@ test("Invalid entrypoint JSON", async () => {
1591
1574
test ( "Resource parameters can be retrieved" , async ( ) => {
1592
1575
const fetchSpy = vi . spyOn ( globalThis , "fetch" ) ;
1593
1576
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 ) ) ,
1598
1579
http . get ( "http://localhost/books" , ( ) =>
1599
- HttpResponse . json ( resourceCollectionWithParameters , init ) ,
1580
+ Response . json ( resourceCollectionWithParameters , init ) ,
1600
1581
) ,
1601
1582
) ;
1602
1583
0 commit comments