fix: update logic for unenrollment (#36)

This commit is contained in:
leangseu-edx
2022-10-07 11:08:00 -04:00
committed by GitHub
parent b327e49f14
commit ab2bf89e25
10 changed files with 66 additions and 75 deletions

View File

@@ -4,6 +4,7 @@ import * as utils from './utils';
jest.mock('query-string', () => ({
stringifyUrl: jest.fn((url, options) => ({ url, options })),
stringify: jest.fn((data) => data),
}));
jest.mock('@edx/frontend-platform/auth', () => ({
getAuthenticatedHttpClient: jest.fn(),
@@ -22,8 +23,15 @@ describe('lms service utils', () => {
it('forwards arguments to authenticatedHttpClient().post', () => {
const post = jest.fn((...args) => ({ post: args }));
getAuthenticatedHttpClient.mockReturnValue({ post });
const args = ['some', 'args', 'for', 'the', 'test'];
expect(utils.post(...args)).toEqual(post(...args));
const url = 'some url';
const body = {
some: 'body',
for: 'the',
test: 'yay',
};
const expectedUrl = utils.post(url, body);
expect(queryString.stringify).toHaveBeenCalledWith(body);
expect(expectedUrl).toEqual(post(url, body));
});
});
describe('stringifyUrl', () => {