Skip to content

Commit

Permalink
Add OneSignal-Subscription-Id header unit tests
Browse files Browse the repository at this point in the history
Adds OneSignal-Subscription-Id header unit test for create and update user requests. Also adds refresh_device_metadata test for create user
  • Loading branch information
shepherd-l committed Mar 5, 2024
1 parent 48777f2 commit 0cbdc2d
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion __test__/unit/http/sdkVersion.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import Environment from '../../../src/shared/helpers/Environment';
import { RequestService } from '../../../src/core/requestService/RequestService';
import { APP_ID, DUMMY_EXTERNAL_ID } from '../../support/constants';
import {
APP_ID,
DUMMY_EXTERNAL_ID,
DUMMY_SUBSCRIPTION_ID,
} from '../../support/constants';
import { expectHeaderToBeSent } from '../../support/helpers/sdkVersion';
import AliasPair from '../../../src/core/requestService/AliasPair';
import { getDummyPushSubscriptionOSModel } from '../../support/helpers/core';
Expand Down Expand Up @@ -46,6 +50,20 @@ describe('Sdk Version Header Tests', () => {
RequestService.createUser({ appId: APP_ID }, {});
expectHeaderToBeSent();
});
test('POST /users: header is sent', () => {
RequestService.createUser(
{ appId: APP_ID },
{ refresh_device_metadata: true },
);
expectHeaderToBeSent();
});
test('POST /users: header is sent with subscription id', () => {
RequestService.createUser(
{ appId: APP_ID, subscriptionId: DUMMY_SUBSCRIPTION_ID },
{},
);
expectHeaderToBeSent();
});
test('GET /users/by/<alias_label>/<alias_id>: header is sent', () => {
RequestService.getUser(
{ appId: APP_ID },
Expand All @@ -61,6 +79,14 @@ describe('Sdk Version Header Tests', () => {
);
expectHeaderToBeSent();
});
test('PATCH /users/by/<alias_label>/<alias_id>: header is sent with subscription id', () => {
RequestService.updateUser(
{ appId: APP_ID, subscriptionId: DUMMY_SUBSCRIPTION_ID },
new AliasPair(AliasPair.EXTERNAL_ID, DUMMY_EXTERNAL_ID),
{},
);
expectHeaderToBeSent();
});
test('DELETE /users/by/<alias_label>/<alias_id>: header is sent', () => {
RequestService.deleteUser(
{ appId: APP_ID },
Expand Down

0 comments on commit 0cbdc2d

Please sign in to comment.