@inrupt/solid-client

Globals / “resource/mock”

Module: “resource/mock”

Functions

mockContainerFrom

mockContainerFrom(url: Url | UrlString): Unpromisify<ReturnType<typeof getSolidDataset>>

Defined in src/resource/mock.ts:81

Warning

Do not use this function in production code. For use in unit tests.

This function initialises a new Container SolidDataset with metadata as though the Container has been retrieved from the given URL. The mock SolidDataset can be used in unit tests that require persisted Containers; e.g., unit tests that call isContainer.

since 0.2.0

Parameters:

Name

Type

Description

url

Url | UrlString

The URL from which the returned Container appears to be retrieved. The url must end in a slash.

Returns: Unpromisify<ReturnType<typeof getSolidDataset>>

A mock SolidDataset that appears to be retrieved from the url.


mockFetchError

mockFetchError(fetchedUrl: UrlString, statusCode?: number): FetchError

Defined in src/resource/mock.ts:144

Warning

Do not use this function in production code. For use in unit tests.

This function initialises a new Error object with metadata as though the it was the result of getting a 404 when trying to fetch the Resource at the given URL. The mock Error can be used in unit tests that require functions that fetch Resources (like getSolidDataset) to fail.

since 1.1.0

Parameters:

Name

Type

Default value

Description

fetchedUrl

UrlString

-

-

statusCode

number

404

Optional status code (defaults to 404) that caused the error.

Returns: FetchError

A mock Error that represents not having been able to fetch the Resource at url due to a 404 Response.


mockFileFrom

mockFileFrom(url: Url | UrlString, options?: Partial<{ contentType: WithServerResourceInfo[“internal_resourceInfo”][“contentType”] }>): Unpromisify<ReturnType<typeof getFile>>

Defined in src/resource/mock.ts:107

Warning

Do not use this function in production code. For use in unit tests.

This function initialises a new File with metadata as though the File has been retrieved from the given URL. The mock File can be used in unit tests that require persisted Files; e.g. unit tests that call getSourceUrl.

since 0.2.0

Parameters:

Name

Type

Description

url

Url | UrlString

The URL from which the returned File appears to be retrieved.

options?

Partial<{ contentType: WithServerResourceInfo[“internal_resourceInfo”][“contentType”] }>

-

Returns: Unpromisify<ReturnType<typeof getFile>>

A mock File that appears to be retrieved from the url.


mockSolidDatasetFrom

mockSolidDatasetFrom(url: Url | UrlString): Unpromisify<ReturnType<typeof getSolidDataset>>

Defined in src/resource/mock.ts:51

Warning

Do not use this function in production code. For use in unit tests.

This function initialises a new SolidDataset with metadata as though the SolidDataset has been retrieved from the given URL. The mock SolidDataset can be used in unit tests that require persisted SolidDatasets; e.g., unit tests that call getSourceUrl.

since 0.2.0

Parameters:

Name

Type

Description

url

Url | UrlString

The URL from which the returned SolidDataset appears to be retrieved.

Returns: Unpromisify<ReturnType<typeof getSolidDataset>>

A mock SolidDataset that appears to be retrieved from the url.