-
Notifications
You must be signed in to change notification settings - Fork 730
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 lessons loading in one place
- Loading branch information
Showing
4 changed files
with
82 additions
and
36 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
kolibri/plugins/coach/assets/src/composables/__mocks__/useLessons.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 @@ | ||
/** | ||
* `useLessons` composable function mock. | ||
* | ||
* If default values are sufficient for tests, | ||
* you only need call `jest.mock('<useLessons 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 `useLessonsMock` that accepts | ||
* an object with values to be overriden and use it together | ||
* with `mockImplementation` as follows: | ||
* | ||
* ``` | ||
* // eslint-disable-next-line import/named | ||
* import useLessons, { useLessonsMock } from '<useLessons file path>'; | ||
* | ||
* jest.mock('<useLessons file path>') | ||
* | ||
* it('test', () => { | ||
* useLessons.mockImplementation( | ||
* () => useLessonsMock({ lessonsAreLoading: true }) | ||
* ); | ||
* }) | ||
* ``` | ||
* | ||
* You can reset your mock implementation back to default values | ||
* for other tests by calling the following in `beforeEach`: | ||
* | ||
* ``` | ||
* useLessons.mockImplementation(() => useLessonsMock()) | ||
* ``` | ||
*/ | ||
|
||
const MOCK_DEFAULTS = { | ||
lessonsAreLoading: false, | ||
showLessonsRootPage: jest.fn(), | ||
}; | ||
|
||
export function useLessonsMock(overrides = {}) { | ||
return { | ||
...MOCK_DEFAULTS, | ||
...overrides, | ||
}; | ||
} | ||
|
||
export default jest.fn(() => useLessonsMock()); |
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
34 changes: 0 additions & 34 deletions
34
kolibri/plugins/coach/assets/src/modules/lessonsRoot/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