-
Notifications
You must be signed in to change notification settings - Fork 633
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 #8430 from MisRob/learn-home
Hybrid learning home page MVP - for string freeze
- Loading branch information
Showing
39 changed files
with
2,597 additions
and
313 deletions.
There are no files selected for viewing
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
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,3 @@ | ||
export const LearnerClassroomResource = { | ||
fetchCollection: jest.fn(), | ||
}; |
46 changes: 46 additions & 0 deletions
46
kolibri/plugins/learn/assets/src/composables/__mocks__/useDeviceSettings.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 @@ | ||
/** | ||
* `useDeviceSettings` composable function mock. | ||
* | ||
* If default values are sufficient for tests, | ||
* you only need call `jest.mock('<useDeviceSettings 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 `useDeviceSettingsMock` that accepts | ||
* an object with values to be overriden and use it together | ||
* with `mockImplementation` as follows: | ||
* | ||
* ``` | ||
* // eslint-disable-next-line import/named | ||
* import useDeviceSettings, { useDeviceSettingsMock } from '<useDeviceSettings file path>'; | ||
* | ||
* jest.mock('<useDeviceSettings file path>') | ||
* | ||
* it('test', () => { | ||
* useDeviceSettings.mockImplementation( | ||
* () => useDeviceSettingsMock({ allowGuestAccess: true }) | ||
* ); | ||
* }) | ||
* ``` | ||
* | ||
* You can reset your mock implementation back to default values | ||
* for other tests by calling the following in `beforeEach`: | ||
* | ||
* ``` | ||
* useDeviceSettings.mockImplementation(() => useDeviceSettingsMock()) | ||
* ``` | ||
*/ | ||
|
||
const MOCK_DEFAULTS = { | ||
allowGuestAccess: false, | ||
canAccessUnassignedContent: false, | ||
}; | ||
|
||
export function useDeviceSettingsMock(overrides = {}) { | ||
return { | ||
...MOCK_DEFAULTS, | ||
...overrides, | ||
}; | ||
} | ||
|
||
export default jest.fn(() => useDeviceSettingsMock()); |
55 changes: 55 additions & 0 deletions
55
kolibri/plugins/learn/assets/src/composables/__mocks__/useLearnerResources.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,55 @@ | ||
/** | ||
* `useLearnerResources` composable function mock. | ||
* | ||
* If default values are sufficient for tests, | ||
* you only need call `jest.mock('<useLearnerResources 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 `useLearnerResourcesMock` that accepts | ||
* an object with values to be overriden and use it together | ||
* with `mockImplementation` as follows: | ||
* | ||
* ``` | ||
* // eslint-disable-next-line import/named | ||
* import useLearnerResources, { useLearnerResourcesMock } from '<useLearnerResources file path>'; | ||
* | ||
* jest.mock('<useLearnerResources file path>') | ||
* | ||
* it('test', () => { | ||
* useLearnerResources.mockImplementation( | ||
* () => useLearnerResourcesMock({ classes: [{ id: 'class-1' }] }) | ||
* ); | ||
* }) | ||
* ``` | ||
* | ||
* You can reset your mock implementation back to default values | ||
* for other tests by calling the following in `beforeEach`: | ||
* | ||
* ``` | ||
* useLearnerResources.mockImplementation(() => useLearnerResourcesMock()) | ||
* ``` | ||
*/ | ||
|
||
const MOCK_DEFAULTS = { | ||
classes: [], | ||
resumableClassesQuizzes: [], | ||
resumableClassesResources: [], | ||
resumableNonClassesContentNodes: [], | ||
getClass: jest.fn(), | ||
getResumableContentNode: jest.fn(), | ||
getClassQuizLink: jest.fn(), | ||
getClassResourceLink: jest.fn(), | ||
getTopicContentNodeLink: jest.fn(), | ||
fetchClasses: jest.fn(), | ||
fetchResumableContentNodes: jest.fn(), | ||
}; | ||
|
||
export function useLearnerResourcesMock(overrides = {}) { | ||
return { | ||
...MOCK_DEFAULTS, | ||
...overrides, | ||
}; | ||
} | ||
|
||
export default jest.fn(() => useLearnerResourcesMock()); |
45 changes: 45 additions & 0 deletions
45
kolibri/plugins/learn/assets/src/composables/__mocks__/useUser.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,45 @@ | ||
/** | ||
* `useUser` composable function mock. | ||
* | ||
* If default values are sufficient for tests, | ||
* you only need call `jest.mock('<useUser 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 `useUserMock` that accepts | ||
* an object with values to be overriden and use it together | ||
* with `mockImplementation` as follows: | ||
* | ||
* ``` | ||
* // eslint-disable-next-line import/named | ||
* import useUser, { useUserMock } from '<useUser file path>'; | ||
* | ||
* jest.mock('<useUser file path>') | ||
* | ||
* it('test', () => { | ||
* useUser.mockImplementation( | ||
* () => useUserMock({ isUserLoggedIn: true }) | ||
* ); | ||
* }) | ||
* ``` | ||
* | ||
* You can reset your mock implementation back to default values | ||
* for other tests by calling the following in `beforeEach`: | ||
* | ||
* ``` | ||
* useUser.mockImplementation(() => useUserMock()) | ||
* ``` | ||
*/ | ||
|
||
const MOCK_DEFAULTS = { | ||
isUserLoggedIn: false, | ||
}; | ||
|
||
export function useUserMock(overrides = {}) { | ||
return { | ||
...MOCK_DEFAULTS, | ||
...overrides, | ||
}; | ||
} | ||
|
||
export default jest.fn(() => useUserMock()); |
Oops, something went wrong.