@inrupt/solid-client / resource/mock

Module: resource/mock

Table of contents

Functions

Functions

mockContainerFrom

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

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.

Defined in: src/resource/mock.ts:81


mockFetchError

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

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.

Defined in: src/resource/mock.ts:144


mockFileFrom

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

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.

Defined in: src/resource/mock.ts:107


mockSolidDatasetFrom

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

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.

Defined in: src/resource/mock.ts:51