@@ -3360,8 +3360,8 @@ describe("getWellKnownSolid", () => {
33603360 const mockESS = ( ) =>
33613361 jest . spyOn ( globalThis , "fetch" ) . mockImplementation ( essDiscoveryDoc ) ;
33623362
3363- it ( "fetches root well known solid by default" , async ( ) => {
3364- // Fetches root well known
3363+ it ( "fetches root well- known solid by default" , async ( ) => {
3364+ // Fetches root well- known
33653365 mockESS ( ) ;
33663366
33673367 await getWellKnownSolid ( resourceUrl ) ;
@@ -3373,109 +3373,17 @@ describe("getWellKnownSolid", () => {
33733373 ) ;
33743374 } ) ;
33753375
3376- it ( "uses the given fetcher for root well known solid if provided" , async ( ) => {
3377- const mockFetch = jest . fn < typeof fetch > ( essDiscoveryDoc ) ;
3378-
3379- await getWellKnownSolid ( resourceUrl , { fetch : mockFetch } ) ;
3380-
3381- expect ( mockFetch ) . toHaveBeenCalledTimes ( 0 ) ;
3382- // Unauthenticated fetch is still used to get the .well-known
3383- expect ( fetch ) . toHaveBeenCalledTimes ( 1 ) ;
3384- expect ( fetch ) . toHaveBeenCalledWith (
3385- serverUrl . concat ( wellKnownSolid ) ,
3386- expect . anything ( ) ,
3387- ) ;
3388- } ) ;
3389-
3390- it ( "appends a / to the Pod root if missing before appending .well-known/solid" , async ( ) => {
3391- const spyFetch = jest . spyOn ( globalThis , "fetch" ) ;
3392-
3393- // Root cannot be fetched
3394- spyFetch . mockResolvedValueOnce ( new Response ( undefined , { status : 404 } ) ) ;
3395- // Resource advertises Pod root
3396- spyFetch . mockResolvedValueOnce (
3397- mockResponse (
3398- undefined ,
3399- {
3400- headers : {
3401- "Content-Type" : "text/turtle" ,
3402- link : `</username>; rel="http://www.w3.org/ns/pim/space#storage"` ,
3403- } ,
3404- } ,
3405- resourceUrl ,
3406- ) ,
3407- ) ;
3408- // Fetches Pod root well known
3409- spyFetch . mockResolvedValueOnce (
3410- new Response (
3411- `{
3412- "@context":"https://pod.inrupt.com/solid/v1",
3413- "consent":"https://consent.pod.inrupt.com",
3414- "notificationGateway":"https://notification.pod.inrupt.com",
3415- "powerSwitch":"https://pod.inrupt.com/powerswitch/username",
3416- "storage":"https://pod.inrupt.com/username/"
3417- }` ,
3418- {
3419- headers : {
3420- "Content-Type" : "application/ld+json" ,
3421- } ,
3422- } ,
3423- ) ,
3424- ) ;
3425-
3426- await getWellKnownSolid ( resourceUrl ) ;
3427-
3428- expect ( spyFetch . mock . calls ) . toHaveLength ( 3 ) ;
3429-
3430- // Tries the root well known solid first is used to determine well known Solid
3431- expect ( spyFetch . mock . calls [ 0 ] [ 0 ] ) . toBe ( serverUrl . concat ( wellKnownSolid ) ) ;
3432- // Checks the resource's location header otherwise
3433- expect ( spyFetch . mock . calls [ 1 ] [ 0 ] ) . toBe ( resourceUrl ) ;
3434- // The advertised podIdentifier (as storage) is used to determine well known Solid
3435- expect ( spyFetch . mock . calls [ 2 ] [ 0 ] ) . toBe (
3436- serverUrl . concat ( "username/" , wellKnownSolid ) ,
3437- ) ;
3438- } ) ;
3439-
3440- it ( "Throws an error if the resource metadata can't be fetched" , async ( ) => {
3441- const spyFetch = jest . spyOn ( globalThis , "fetch" ) ;
3442-
3443- // Can't fetch root well known
3444- spyFetch . mockResolvedValueOnce ( new Response ( undefined , { status : 404 } ) ) ;
3445- // Resource advertises Pod root
3446- spyFetch . mockResolvedValueOnce (
3447- mockResponse (
3448- undefined ,
3449- {
3450- headers : {
3451- "Content-Type" : "text/turtle" ,
3452- link : `</username>; rel="http://www.w3.org/ns/pim/space#storage"` ,
3453- } ,
3454- } ,
3455- resourceUrl ,
3456- ) ,
3457- ) ;
3458- // Can't fetch pod root well known solid
3459- spyFetch . mockResolvedValueOnce ( new Response ( undefined , { status : 404 } ) ) ;
3460-
3461- await expect ( getWellKnownSolid ( resourceUrl ) ) . rejects . toThrow ( ) ;
3462-
3463- expect ( spyFetch . mock . calls ) . toHaveLength ( 3 ) ;
3464- } ) ;
3465-
3466- it ( "Throws an error if the pod root cannot be determined" , async ( ) => {
3376+ it ( "Throws an error if the well-known solid resource cannot be found" , async ( ) => {
34673377 const spyFetch = jest . spyOn ( globalThis , "fetch" ) ;
34683378
3469- // Can't fetch root well known
3379+ // Can't fetch root well- known
34703380 spyFetch . mockResolvedValueOnce ( new Response ( undefined , { status : 404 } ) ) ;
3471- // Resource does not advertise pod root
3472- spyFetch . mockResolvedValueOnce ( new Response ( undefined ) ) ;
34733381
34743382 await expect ( getWellKnownSolid ( resourceUrl ) ) . rejects . toThrow (
34753383 "Could not determine storage root or well-known solid resource." ,
34763384 ) ;
34773385
3478- expect ( spyFetch . mock . calls ) . toHaveLength ( 2 ) ;
3386+ expect ( spyFetch . mock . calls ) . toHaveLength ( 1 ) ;
34793387 } ) ;
34803388
34813389 it ( "returns the contents of .well-known/solid for the given resource" , async ( ) => {
0 commit comments