@@ -3338,14 +3338,14 @@ describe("getWellKnownSolid", () => {
33383338 const resourceUrl = "https://example.org/pod/resource" ;
33393339 const wellKnownSolid = ".well-known/solid" ;
33403340
3341- const ess20Implementation : typeof fetch = async ( ) =>
3341+ const essDiscoveryDoc : typeof fetch = async ( ) =>
33423342 new Response (
33433343 `@prefix solid: <http://www.w3.org/ns/solid/terms#> .
33443344
33453345[
33463346 a solid:DiscoveryDocument ;
33473347 <http://www.w3.org/ns/auth/acl#trustedApp>
3348- <https://podbrowser. inrupt.com/api/app > ;
3348+ <https://inrupt.com> ;
33493349 solid:maxPodsPerOwner 10 ;
33503350 solid:notificationGateway <https://notification.inrupt.com/> ;
33513351 solid:provision <https://provision.inrupt.com/> ;
@@ -3358,56 +3358,12 @@ describe("getWellKnownSolid", () => {
33583358 } ,
33593359 ) ;
33603360
3361- const ess11Implementation : typeof fetch = async (
3362- url : RequestInfo | URL ,
3363- init ?: RequestInit ,
3364- ) => {
3365- if ( url === "https://example.org/.well-known/solid" ) {
3366- return mockResponse ( undefined , { status : 404 } , url ) ;
3367- }
3368-
3369- if ( url === "https://example.org/pod/resource" ) {
3370- return mockResponse (
3371- undefined ,
3372- {
3373- headers : {
3374- "Content-Type" : "text/turtle" ,
3375- link : `<${ podUrl } >; rel="http://www.w3.org/ns/pim/space#storage"` ,
3376- } ,
3377- } ,
3378- resourceUrl ,
3379- ) ;
3380- }
3381-
3382- if ( url === "https://example.org/pod/.well-known/solid" ) {
3383- return mockResponse (
3384- `
3385- {
3386- "@context":"https://pod.inrupt.com/solid/v1",
3387- "consent":"https://consent.pod.inrupt.com",
3388- "notificationGateway":"https://notification.pod.inrupt.com",
3389- "powerSwitch":"https://pod.inrupt.com/powerswitch/username",
3390- "storage":"https://pod.inrupt.com/username/"
3391- }` ,
3392- {
3393- headers : { "Content-Type" : "application/ld+json" } ,
3394- } ,
3395- url ,
3396- ) ;
3397- }
3398-
3399- throw new Error ( `Unhandled request: ${ url } , ${ JSON . stringify ( init ) } ` ) ;
3400- } ;
3401-
3402- const mockESS20 = ( ) =>
3403- jest . spyOn ( globalThis , "fetch" ) . mockImplementation ( ess20Implementation ) ;
3404-
3405- const mockESS11 = ( ) =>
3406- jest . spyOn ( globalThis , "fetch" ) . mockImplementation ( ess11Implementation ) ;
3361+ const mockESS = ( ) =>
3362+ jest . spyOn ( globalThis , "fetch" ) . mockImplementation ( essDiscoveryDoc ) ;
34073363
34083364 it ( "fetches root well known solid by default" , async ( ) => {
34093365 // Fetches root well known
3410- mockESS20 ( ) ;
3366+ mockESS ( ) ;
34113367
34123368 await getWellKnownSolid ( resourceUrl ) ;
34133369
@@ -3419,7 +3375,7 @@ describe("getWellKnownSolid", () => {
34193375 } ) ;
34203376
34213377 it ( "uses the given fetcher for root well known solid if provided" , async ( ) => {
3422- const mockFetch = jest . fn < typeof fetch > ( ess20Implementation ) ;
3378+ const mockFetch = jest . fn < typeof fetch > ( essDiscoveryDoc ) ;
34233379
34243380 await getWellKnownSolid ( resourceUrl , { fetch : mockFetch } ) ;
34253381
@@ -3432,55 +3388,6 @@ describe("getWellKnownSolid", () => {
34323388 ) ;
34333389 } ) ;
34343390
3435- it ( "fetches pod root well known solid otherwise" , async ( ) => {
3436- mockESS11 ( ) ;
3437-
3438- await getWellKnownSolid ( resourceUrl ) ;
3439-
3440- expect ( fetch ) . toHaveBeenCalledTimes ( 3 ) ;
3441- // Tries the root well known solid first is used to determine well known Solid
3442- expect ( fetch ) . toHaveBeenNthCalledWith (
3443- 1 ,
3444- serverUrl . concat ( wellKnownSolid ) ,
3445- expect . anything ( ) ,
3446- ) ;
3447- // Checks the resource's location header otherwise
3448- expect ( fetch ) . toHaveBeenNthCalledWith ( 2 , resourceUrl , expect . anything ( ) ) ;
3449- // The advertised podIdentifier (as storage) is used to determine well known Solid
3450- expect ( fetch ) . toHaveBeenNthCalledWith (
3451- 3 ,
3452- podUrl . concat ( wellKnownSolid ) ,
3453- expect . anything ( ) ,
3454- ) ;
3455- } ) ;
3456-
3457- it ( "uses the given fetcher for pod root well known solid if provided" , async ( ) => {
3458- const mockFetch = jest . fn < typeof fetch > ( ess11Implementation ) ;
3459-
3460- await getWellKnownSolid ( resourceUrl , { fetch : mockFetch } ) ;
3461-
3462- expect ( mockFetch ) . toHaveBeenCalledTimes ( 2 ) ;
3463- expect ( fetch ) . toHaveBeenCalledTimes ( 1 ) ;
3464- // Tries the root well known solid first is used to determine well known Solid
3465- expect ( fetch ) . toHaveBeenNthCalledWith (
3466- 1 ,
3467- serverUrl . concat ( wellKnownSolid ) ,
3468- expect . anything ( ) ,
3469- ) ;
3470- // Checks the resource's location header otherwise
3471- expect ( mockFetch ) . toHaveBeenNthCalledWith (
3472- 1 ,
3473- resourceUrl ,
3474- expect . anything ( ) ,
3475- ) ;
3476- // The advertised podIdentifier (as storage) is used to determine well known Solid
3477- expect ( mockFetch ) . toHaveBeenNthCalledWith (
3478- 2 ,
3479- podUrl . concat ( wellKnownSolid ) ,
3480- expect . anything ( ) ,
3481- ) ;
3482- } ) ;
3483-
34843391 it ( "appends a / to the Pod root if missing before appending .well-known/solid" , async ( ) => {
34853392 const spyFetch = jest . spyOn ( globalThis , "fetch" ) ;
34863393
@@ -3572,20 +3479,12 @@ describe("getWellKnownSolid", () => {
35723479 expect ( spyFetch . mock . calls ) . toHaveLength ( 2 ) ;
35733480 } ) ;
35743481
3575- it ( "returns the contents of .well-known/solid for the given resource (2.0) " , async ( ) => {
3576- mockESS20 ( ) ;
3482+ it ( "returns the contents of .well-known/solid for the given resource" , async ( ) => {
3483+ mockESS ( ) ;
35773484
35783485 const wellKnownSolidResponse = await getWellKnownSolid ( resourceUrl ) ;
35793486 // skipIf confuses jest
35803487 // eslint-disable-next-line jest/no-standalone-expect
35813488 expect ( wellKnownSolidResponse ) . toMatchSnapshot ( ) ;
35823489 } ) ;
3583-
3584- it ( "returns the contents of .well-known/solid for the given resource (1.1)" , async ( ) => {
3585- mockESS11 ( ) ;
3586-
3587- const wellKnownSolidResponse = await getWellKnownSolid ( resourceUrl ) ;
3588-
3589- expect ( wellKnownSolidResponse ) . toMatchSnapshot ( ) ;
3590- } ) ;
35913490} ) ;
0 commit comments