Skip to content

Commit 9e25e21

Browse files
committed
adapting test
1 parent 15194f4 commit 9e25e21

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

niceday-api/index.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ require('isomorphic-fetch');
33
const NICEDAY_TEST_SERVERPORT = 8080;
44
const NICEDAY_TEST_USER_ID = 38527;
55
const NICEDAY_TEST_TRACKER_RRULE = 'DTSTART:20210310T150000\nRRULE:FREQ=DAILY';
6+
const MOCK_ID_FROM = 1;
7+
const MOCK_ID_TO = 12345;
68
const MOCK_USER_DATA = {
79
id: NICEDAY_TEST_USER_ID,
810
userProfile: {
911
firstName: 'Mr Mock',
1012
},
1113
};
14+
const MOCK_TEST_MESSAGE = 'Test message';
1215
const MOCK_TRACKER_RESPONSE = { response: 'mock response' };
1316
const MOCK_SMOKING_TRACKER_RESPONSE = [
1417
{ value: { measures: { measureCigarettes: { sensorData: MOCK_TRACKER_RESPONSE } } } }];
@@ -45,6 +48,24 @@ describe('Tests on niceday-api server using mocked goalie-js', () => {
4548
SenseServerEnvironment: () => ({
4649
Alpha: undefined,
4750
}),
51+
Chat: jest.fn().mockImplementation(() => ({
52+
init: jest.fn(),
53+
connect: jest.fn(),
54+
markMessageAsRead: jest.fn(),
55+
subscribeToConnectionStatusChanges: jest.fn(),
56+
sendInitialPresence: jest.fn(),
57+
subscribeToIncomingMessage: (handler) => {
58+
const mockTestMessage = {
59+
from: MOCK_ID_FROM,
60+
to: MOCK_ID_TO,
61+
content: {
62+
TEXT: MOCK_TEST_MESSAGE,
63+
},
64+
};
65+
66+
handler(mockTestMessage);
67+
},
68+
})),
4869
Contacts: jest.fn().mockImplementation(() => ({
4970
getConnectedContacts: () => new Promise((resolve) => {
5071
resolve(MOCK_USER_DATA);

0 commit comments

Comments
 (0)