Skip to content

Commit 16ea922

Browse files
committed
added removecontact test
1 parent 084832e commit 16ea922

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

niceday-api/index.test.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const MOCK_PENDING_REQUESTS = [
2424
invitationId: MOCK_REQUEST_ID,
2525
},
2626
];
27-
const MOCK_ACCEPT_REQUESTS = {};
27+
const MOCK_EMPTY_RESPONSE = {};
2828

2929
// Contains all tests which require a mocked Senseserver
3030
describe('Tests on niceday-api server using mocked goalie-js', () => {
@@ -53,7 +53,10 @@ describe('Tests on niceday-api server using mocked goalie-js', () => {
5353
resolve(MOCK_PENDING_REQUESTS);
5454
}),
5555
acceptInvitation: () => new Promise((resolve) => {
56-
resolve(MOCK_ACCEPT_REQUESTS);
56+
resolve(MOCK_EMPTY_RESPONSE);
57+
}),
58+
removeContactFromUserContact: () => new Promise((resolve) => {
59+
resolve(MOCK_EMPTY_RESPONSE);
5760
}),
5861
})),
5962
Authentication: jest.fn().mockImplementation(() => ({
@@ -234,7 +237,30 @@ describe('Tests on niceday-api server using mocked goalie-js', () => {
234237
})
235238
.then((response) => response.json())
236239
.then((responseBody) => {
237-
expect(responseBody).toEqual(MOCK_ACCEPT_REQUESTS);
240+
expect(responseBody).toEqual(MOCK_EMPTY_RESPONSE);
241+
})
242+
.catch((error) => {
243+
throw new Error(`Error during fetch: ${error}`);
244+
});
245+
});
246+
247+
it('Test remove contact /removecontact endpoint', () => {
248+
/*
249+
Sends a POST to the /acceptconnection endpoint.
250+
*/
251+
252+
const urlreq = `http://localhost:${NICEDAY_TEST_SERVERPORT}/removecontact`;
253+
const data = JSON.stringify({
254+
user_id: NICEDAY_TEST_USER_ID.toString(),
255+
});
256+
return fetch(urlreq, {
257+
method: 'post',
258+
headers: { 'Content-Type': 'application/json' },
259+
body: data,
260+
})
261+
.then((response) => response.json())
262+
.then((responseBody) => {
263+
expect(responseBody).toEqual(MOCK_EMPTY_RESPONSE);
238264
})
239265
.catch((error) => {
240266
throw new Error(`Error during fetch: ${error}`);

0 commit comments

Comments
 (0)