Skip to content

Commit

Permalink
api calls tests (#95)
Browse files Browse the repository at this point in the history
* add basic structure for auth mock

* api test fixup

* eslint fixup

* verification details api tests

* verification status

* entitlements

* getUser tests

* get all user data

* course data and password status toggle

* test re-ordering

* enrollment tests
  • Loading branch information
DawoudSheraz authored Mar 17, 2021
1 parent 8c00fef commit 6b0bb8b
Show file tree
Hide file tree
Showing 6 changed files with 615 additions and 1 deletion.
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
},
"devDependencies": {
"@edx/frontend-build": "^5.5.1",
"axios-mock-adapter": "^1.19.0",
"check-prop-types": "1.1.2",
"codecov": "3.8.1",
"enzyme": "3.11.0",
Expand Down
19 changes: 19 additions & 0 deletions src/setupTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@ import 'babel-polyfill';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import checkPropTypes from 'check-prop-types';
import { initialize, mergeConfig } from '@edx/frontend-platform';
import { MockAuthService } from '@edx/frontend-platform/auth';

Enzyme.configure({ adapter: new Adapter() });

initialize({
handlers: {
config: () => {
mergeConfig({
authenticatedUser: {
userId: 'abc123',
username: 'Mock User',
roles: [],
administrator: false,
},
});
},
},
messages: [],
authService: MockAuthService,
});

// eslint-disable-next-line import/prefer-default-export
export function checkProps(component, expectedProps) {
return checkPropTypes(
Expand Down
2 changes: 1 addition & 1 deletion src/users/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export async function postEnrollmentChange({
code: null,
dismissible: true,
text:
'There was an error submitting this entitlement. Check the JavaScript console for detailed errors.',
'There was an error submitting this enrollment. Check the JavaScript console for detailed errors.',
type: 'danger',
topic: 'enrollments',
},
Expand Down
Loading

0 comments on commit 6b0bb8b

Please sign in to comment.