Skip to content

Commit

Permalink
Extract shared subject
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace committed Jul 7, 2022
1 parent 9e3f941 commit 99cb71c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/hub/node-tests/services/in-app-purchases-test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import InAppPurchases from '../../services/in-app-purchases';
import { setupHub } from '../helpers/server';
import { rest } from 'msw';
import { setupServer, SetupServerApi } from 'msw/node';
import config from 'config';

describe('InAppPurchases', function () {
let { getContainer } = setupHub(this);
let subject: InAppPurchases;

this.beforeEach(async function () {
subject = await getContainer().lookup('in-app-purchases');
});

describe('for Apple provider', function () {
let mockServer: SetupServerApi;
Expand All @@ -27,7 +33,6 @@ describe('InAppPurchases', function () {
});

it('passes along a successful validation', async function () {
let subject = await getContainer().lookup('in-app-purchases');
let validationResponse = await subject.validate('apple', 'VALID_RECEIPT');

expect(receiptSentToServer).to.equal('VALID_RECEIPT');
Expand All @@ -39,7 +44,6 @@ describe('InAppPurchases', function () {
});

it('passes along a failed validation', async function () {
let subject = await getContainer().lookup('in-app-purchases');
let validationResponse = await subject.validate('apple', 'INVALID_RECEIPT');

expect(receiptSentToServer).to.equal('INVALID_RECEIPT');
Expand Down Expand Up @@ -72,7 +76,6 @@ describe('InAppPurchases', function () {
});

it('passes along a successful validation', async function () {
let subject = await getContainer().lookup('in-app-purchases');
let validationResponse = await subject.validate('google', 'VALID_RECEIPT');

expect(receiptSentToServer).to.equal('VALID_RECEIPT');
Expand All @@ -84,7 +87,6 @@ describe('InAppPurchases', function () {
});

it('passes along a failed validation', async function () {
let subject = await getContainer().lookup('in-app-purchases');
let validationResponse = await subject.validate('google', 'INVALID_RECEIPT');

expect(receiptSentToServer).to.equal('INVALID_RECEIPT');
Expand All @@ -96,7 +98,6 @@ describe('InAppPurchases', function () {
});

it('passes along a failed validation for a canceled purchase', async function () {
let subject = await getContainer().lookup('in-app-purchases');
let validationResponse = await subject.validate('google', 'CANCELED_RECEIPT');

expect(validationResponse).to.deep.equal({
Expand Down

0 comments on commit 99cb71c

Please sign in to comment.