Skip to content

Commit

Permalink
added removecontact test
Browse files Browse the repository at this point in the history
  • Loading branch information
wbaccinelli committed Jun 16, 2023
1 parent 084832e commit 16ea922
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions niceday-api/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const MOCK_PENDING_REQUESTS = [
invitationId: MOCK_REQUEST_ID,
},
];
const MOCK_ACCEPT_REQUESTS = {};
const MOCK_EMPTY_RESPONSE = {};

// Contains all tests which require a mocked Senseserver
describe('Tests on niceday-api server using mocked goalie-js', () => {
Expand Down Expand Up @@ -53,7 +53,10 @@ describe('Tests on niceday-api server using mocked goalie-js', () => {
resolve(MOCK_PENDING_REQUESTS);
}),
acceptInvitation: () => new Promise((resolve) => {
resolve(MOCK_ACCEPT_REQUESTS);
resolve(MOCK_EMPTY_RESPONSE);
}),
removeContactFromUserContact: () => new Promise((resolve) => {
resolve(MOCK_EMPTY_RESPONSE);
}),
})),
Authentication: jest.fn().mockImplementation(() => ({
Expand Down Expand Up @@ -234,7 +237,30 @@ describe('Tests on niceday-api server using mocked goalie-js', () => {
})
.then((response) => response.json())
.then((responseBody) => {
expect(responseBody).toEqual(MOCK_ACCEPT_REQUESTS);
expect(responseBody).toEqual(MOCK_EMPTY_RESPONSE);
})
.catch((error) => {
throw new Error(`Error during fetch: ${error}`);
});
});

it('Test remove contact /removecontact endpoint', () => {
/*
Sends a POST to the /acceptconnection endpoint.
*/

const urlreq = `http://localhost:${NICEDAY_TEST_SERVERPORT}/removecontact`;
const data = JSON.stringify({
user_id: NICEDAY_TEST_USER_ID.toString(),
});
return fetch(urlreq, {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: data,
})
.then((response) => response.json())
.then((responseBody) => {
expect(responseBody).toEqual(MOCK_EMPTY_RESPONSE);
})
.catch((error) => {
throw new Error(`Error during fetch: ${error}`);
Expand Down

0 comments on commit 16ea922

Please sign in to comment.