-
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.
to keep the logic related to groups loading in one place
- Loading branch information
Showing
4 changed files
with
106 additions
and
60 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
kolibri/plugins/coach/assets/src/composables/__mocks__/useGroups.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,46 @@ | ||
/** | ||
* `useGroups` composable function mock. | ||
* | ||
* If default values are sufficient for tests, | ||
* you only need call `jest.mock('<useGroups 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 `useGroupsMock` that accepts | ||
* an object with values to be overriden and use it together | ||
* with `mockImplementation` as follows: | ||
* | ||
* ``` | ||
* // eslint-disable-next-line import/named | ||
* import useGroups, { useGroupsMock } from '<useGroups file path>'; | ||
* | ||
* jest.mock('<useGroups file path>') | ||
* | ||
* it('test', () => { | ||
* useGroups.mockImplementation( | ||
* () => useGroupsMock({ groupsAreLoading: true }) | ||
* ); | ||
* }) | ||
* ``` | ||
* | ||
* You can reset your mock implementation back to default values | ||
* for other tests by calling the following in `beforeEach`: | ||
* | ||
* ``` | ||
* useGroups.mockImplementation(() => useGroupsMock()) | ||
* ``` | ||
*/ | ||
|
||
const MOCK_DEFAULTS = { | ||
groupsAreLoading: false, | ||
showGroupsPage: jest.fn(), | ||
}; | ||
|
||
export function useGroupsMock(overrides = {}) { | ||
return { | ||
...MOCK_DEFAULTS, | ||
...overrides, | ||
}; | ||
} | ||
|
||
export default jest.fn(() => useGroupsMock()); |
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
58 changes: 0 additions & 58 deletions
58
kolibri/plugins/coach/assets/src/modules/groups/handlers.js
This file was deleted.
Oops, something went wrong.
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