Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/remove skipped test cases #472

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions __tests__/Util-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const mockedAxios = axios as jest.Mocked<typeof axios>;

describe('getUserData util', () => {
const token = '12345421ac1aca';
const invalidToken = 'a1b9c2d8x3y7z4';

const mockUserData = {
id: '123abc',
Expand All @@ -29,12 +30,16 @@ describe('getUserData util', () => {
username: 'anish-pawaskar',
};

test.skip('when url passed !== redirect url return null', async () => {
const res = await getUserData('https://www.example.net/');
expect(res).toEqual(null);
test('when token passed is invalid, axios call returns with 401', async () => {
mockedAxios.get.mockRejectedValue('401: Unauthorized');
try {
await getUserData(invalidToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the function accepting token or userId?

Copy link
Contributor Author

@abhisheksharmayt abhisheksharmayt Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token
image

} catch (err) {
expect(err).toEqual('401: Unauthorized');
}
});

test('when redirect url is passed to getUserData && axios call is ok return user name & profileUrl', async () => {
test('when token is passed to getUserData && axios call is ok return user name & profileUrl', async () => {
mockedAxios.get.mockResolvedValue({ data: mockUserData });
const res = await getUserData(token);
expect(mockedAxios.get).toHaveBeenCalledWith(`${urls.GET_USERS_DATA}`, {
Expand All @@ -55,17 +60,17 @@ describe('getUserData util', () => {
});
});

test('when redirect url is passed to getUserData && axios call fails return null', async () => {
test('when token is passed to getUserData && axios call fails return null', async () => {
mockedAxios.get.mockRejectedValue('500: server error');
try {
await getUserData(urls.REDIRECT_URL);
await getUserData(token);
} catch (err) {
expect(err).toEqual('500: server error');
}
});
});

describe.skip('updateStatus util', () => {
describe('updateStatus util', () => {
test('pass arg undefined receive throw error', async () => {
mockedAxios.patch.mockRejectedValue(
// eslint-disable-next-line quotes
Expand Down Expand Up @@ -104,7 +109,7 @@ describe.skip('updateStatus util', () => {
});
});

describe.skip('updateMarkYourSelfAs_ util', () => {
describe('updateMarkYourSelfAs_ util', () => {
test('pass arg undefined receive throw error', async () => {
mockedAxios.patch.mockRejectedValue(
// eslint-disable-next-line quotes
Expand Down
Loading