@inrupt/solid-client / resource/mock
Module: resource/mock#
Functions#
mockContainerFrom#
▸ mockContainerFrom(url
): 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]].
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The URL from which the returned Container appears to be retrieved. The |
Returns#
Unpromisify
<ReturnType
<typeof getSolidDataset
>>
A mock SolidDataset that appears to be retrieved from the url
.
Since
0.2.0
Defined in#
src/resource/mock.ts:82
mockFetchError#
▸ mockFetchError(fetchedUrl
, statusCode?
, statusText?
): 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.
Parameters#
Name |
Type |
Default value |
Description |
---|---|---|---|
|
|
|
- |
|
|
|
Optional status code (defaults to 404) that caused the error. |
|
|
|
- |
Returns#
A mock Error that represents not having been able to fetch the Resource at url
due to a 404 Response.
Since
1.1.0
Defined in#
src/resource/mock.ts:145
mockFileFrom#
▸ mockFileFrom(url
, options?
): 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]].
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The URL from which the returned File appears to be retrieved. |
|
|
- |
Returns#
Unpromisify
<ReturnType
<typeof getFile
>>
A mock File that appears to be retrieved from the url
.
Since
0.2.0
Defined in#
src/resource/mock.ts:108
mockSolidDatasetFrom#
▸ mockSolidDatasetFrom(url
): 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]].
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
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
.
Since
0.2.0
Defined in#
src/resource/mock.ts:52