-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10580 from akolson/fix-remote-content-browsing-sk…
…ipped-tests Fixes remote content browsing skipped tests
- Loading branch information
Showing
2 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
kolibri/plugins/learn/assets/src/composables/__mocks__/usePinnedDevices.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* `usePinnedDevices` composable function mock. | ||
* | ||
* If default values are sufficient for tests, | ||
* you only need call `jest.mock('<usePinnedDevices file path>')` | ||
* at the top of a test file. | ||
* | ||
* If you need to override some default values from some tests, | ||
* you can import a helper function `usePinnedDevicesMock` that accepts | ||
* an object with values to be overriden and use it together | ||
* with `mockImplementation` as follows: | ||
* | ||
* ``` | ||
* // eslint-disable-next-line import/named | ||
* import usePinnedDevices, { usePinnedDevicesMock } from '<usePinnedDevices file path>'; | ||
* | ||
* jest.mock('<usePinnedDevices file path>') | ||
* | ||
* it('test', () => { | ||
* usePinnedDevices.mockImplementation( | ||
* () => usePinnedDevicesMock({ channels: [{ id: 'channel-1' }] }) | ||
* ); | ||
* }) | ||
* ``` | ||
* | ||
* You can reset your mock implementation back to default values | ||
* for other tests by calling the following in `beforeEach`: | ||
* | ||
* ``` | ||
* usePinnedDevices.mockImplementation(() => usePinnedDevicesMock()) | ||
* ``` | ||
*/ | ||
|
||
const MOCK_DEFAULTS = { | ||
createPinForUser: jest.fn(() => ''), | ||
deletePinForUser: jest.fn(() => ''), | ||
fetchPinsForUser: jest.fn(() => []), | ||
}; | ||
|
||
export function usePinnedDevicesMock(overrides = {}) { | ||
return { | ||
...MOCK_DEFAULTS, | ||
...overrides, | ||
}; | ||
} | ||
|
||
export default jest.fn(() => usePinnedDevicesMock()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters