Skip to content

Commit

Permalink
feat: add unit test for delete subscription modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke-Tan committed Sep 21, 2023
1 parent 7e06ec0 commit 09dbb3f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/__tests__/subscriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('subscription methods', () => {

const PLAN_ID = 23456;
const SUBSCRIPTION_ID = 34567;
const MODIFIER_ID = 12345;
const PAYMENT_ID = 512345;
const NEW_PAYMENT_DATE = new Date('2023-01-01');

Expand Down Expand Up @@ -620,6 +621,39 @@ describe('subscription methods', () => {
});
});

describe('deleteSubscriptionModifier', () => {
const path = '/subscription/modifiers/delete';
const expectedBody = {
...EXPECTED_BODY,
modifier_id: MODIFIER_ID,
};

// https://developer.paddle.com/classic/api-reference/dcdd0db5b20a1-delete-modifier
const responseBody = {
success: true,
response: {},
};

test('resolves on successful request', async () => {
const scope = nock().post(path, expectedBody).reply(200, responseBody);

const response = await instance.deleteSubscriptionModifier(MODIFIER_ID);

expect(response).toEqual(responseBody.response);
expect(scope.isDone()).toBeTruthy();
});

test('rejects on error request', async () => {
const scope = nock().post(path, expectedBody).reply(400, DEFAULT_ERROR);

await expect(
instance.deleteSubscriptionModifier(MODIFIER_ID)
).rejects.toThrow('Request failed with status code 400');

expect(scope.isDone()).toBeTruthy();
});
});

describe('createOneOffCharge', () => {
const path = `/subscription/${SUBSCRIPTION_ID}/charge`;
const expectedBody = {
Expand Down

0 comments on commit 09dbb3f

Please sign in to comment.