11import { http , HttpResponse } from "msw" ;
2+ import { assert , expect , test } from "vitest" ;
23import { server } from "../../vitest.setup.js" ;
34import fetchJsonLd from "./fetchJsonLd.js" ;
4- import { assert , expect , test } from "vitest" ;
55
66const httpResponse = {
77 "@context" : "http://json-ld.org/contexts/person.jsonld" ,
@@ -33,13 +33,15 @@ test("fetch a JSON-LD document", async () => {
3333
3434test ( "fetch a non JSON-LD document" , async ( ) => {
3535 server . use (
36- http . get ( "http://localhost/foo.jsonld" , ( ) => {
37- return new HttpResponse ( `<body>Hello</body>` , {
38- headers : { "Content-Type" : "text/html" } ,
39- status : 200 ,
40- statusText : "OK" ,
41- } ) ;
42- } ) ,
36+ http . get (
37+ "http://localhost/foo.jsonld" ,
38+ ( ) =>
39+ new HttpResponse ( `<body>Hello</body>` , {
40+ headers : { "Content-Type" : "text/html" } ,
41+ status : 200 ,
42+ statusText : "OK" ,
43+ } ) ,
44+ ) ,
4345 ) ;
4446
4547 const promise = fetchJsonLd ( "http://localhost/foo.jsonld" ) ;
@@ -50,13 +52,13 @@ test("fetch a non JSON-LD document", async () => {
5052
5153test ( "fetch an error with Content-Type application/ld+json" , async ( ) => {
5254 server . use (
53- http . get ( "http://localhost/foo.jsonld" , ( ) => {
54- return HttpResponse . json ( httpResponse , {
55+ http . get ( "http://localhost/foo.jsonld" , ( ) =>
56+ HttpResponse . json ( httpResponse , {
5557 status : 500 ,
5658 statusText : "Internal Server Error" ,
5759 headers : { "Content-Type" : "application/ld+json" } ,
58- } ) ;
59- } ) ,
60+ } ) ,
61+ ) ,
6062 ) ;
6163
6264 const rejectedResponse = await fetchJsonLd (
@@ -72,13 +74,13 @@ test("fetch an error with Content-Type application/ld+json", async () => {
7274
7375test ( "fetch an error with Content-Type application/error+json" , async ( ) => {
7476 server . use (
75- http . get ( "http://localhost/foo.jsonld" , ( ) => {
76- return HttpResponse . json ( httpResponse , {
77+ http . get ( "http://localhost/foo.jsonld" , ( ) =>
78+ HttpResponse . json ( httpResponse , {
7779 status : 400 ,
7880 statusText : "Bad Request" ,
7981 headers : { "Content-Type" : "application/error+json" } ,
80- } ) ;
81- } ) ,
82+ } ) ,
83+ ) ,
8284 ) ;
8385
8486 const rejectedResponse = await fetchJsonLd (
@@ -94,13 +96,15 @@ test("fetch an error with Content-Type application/error+json", async () => {
9496
9597test ( "fetch an empty document" , async ( ) => {
9698 server . use (
97- http . get ( "http://localhost/foo.jsonld" , ( ) => {
98- return new HttpResponse ( `` , {
99- status : 204 ,
100- statusText : "No Content" ,
101- headers : { "Content-Type" : "text/html" } ,
102- } ) ;
103- } ) ,
99+ http . get (
100+ "http://localhost/foo.jsonld" ,
101+ ( ) =>
102+ new HttpResponse ( `` , {
103+ status : 204 ,
104+ statusText : "No Content" ,
105+ headers : { "Content-Type" : "text/html" } ,
106+ } ) ,
107+ ) ,
104108 ) ;
105109
106110 const dataPromise = fetchJsonLd ( "http://localhost/foo.jsonld" ) ;
0 commit comments