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

fixes #115 #116

Merged
merged 7 commits into from
Dec 3, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add one more test case
  • Loading branch information
sonologico committed Dec 2, 2022
commit 3681b2b21251bb1bd79aea38aec0294382729794
38 changes: 38 additions & 0 deletions src/push-notifications.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,44 @@ describe('interest methods', () => {
});
});
});
test('should make correct request with cursor and return the interests', () => {
const instanceId = 'df3c1965-e870-4bd6-8d75-fea56b26335f';

const mockDoRequest = jest.fn();
mockDoRequest.mockReturnValueOnce(
Promise.resolve({
interests: ['donuts'],
responseMetadata: {},
})
);

dorequest.default = mockDoRequest;

const beamsClient = new PusherPushNotifications.Client({
instanceId,
});
return beamsClient.getDeviceInterests(150, 2).then(interests => {
expect(mockDoRequest.mock.calls.length).toBe(1);
expect(mockDoRequest.mock.calls[0].length).toBe(1);
expect(mockDoRequest.mock.calls[0][0]).toEqual({
method: 'GET',
params: {
cursor: 2,
limit: 150,
},
path: [
'https://df3c1965-e870-4bd6-8d75-fea56b26335f.pushnotifications.pusher.com',
'/device_api/v1/instances/df3c1965-e870-4bd6-8d75-fea56b26335f',
'/devices/web/web-1db66b8a-f51f-49de-b225-72591535c855',
'/interests',
].join(''),
});
expect(interests).toEqual({
interests: ['donuts'],
});
});
}
);

test('should fail if SDK is not started', () => {
// Emulate a fresh SDK, where start has not been called
Expand Down