From 291513b54251a74afb701dda8b218f3c7bd69000 Mon Sep 17 00:00:00 2001 From: Deshayes Yann Date: Mon, 26 Jul 2021 09:24:22 +0200 Subject: [PATCH] Add organization payment source test --- test/OrganizationPaymentSource.spec.js | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/OrganizationPaymentSource.spec.js diff --git a/test/OrganizationPaymentSource.spec.js b/test/OrganizationPaymentSource.spec.js new file mode 100644 index 00000000..7fd35ca3 --- /dev/null +++ b/test/OrganizationPaymentSource.spec.js @@ -0,0 +1,42 @@ +/* global beforeEach, afterEach*/ + +import { assert } from "chai"; +import fetchMock from "fetch-mock"; + +import { getConfig } from "../src/config"; +import { setAuthenticationPromise } from "../src/api"; +import OrganizationPaymentSource from "../src/model/OrganizationPaymentSource"; + +describe("OrganizationPaymentSource", () => { + const { api_url } = getConfig(); + + beforeEach(function() { + setAuthenticationPromise(Promise.resolve("testToken")); + }); + + afterEach(function() { + fetchMock.restore(); + }); + + it("Get organization subscription", done => { + fetchMock.mock(`${api_url}/organizations/aliceOrg/payment-source`, { + payment_source: { + data: { exp_month: "1", exp_year: "2024", type: "visa" }, + name: "alice", + number: "XXXX-XXXX-XXXX-4242", + type: "credit-card" + } + }); + + OrganizationPaymentSource.get({ organizationId: "aliceOrg" }).then( + paymentSource => { + assert.equal(paymentSource.name, "alice"); + assert.equal( + paymentSource.constructor.name, + "OrganizationPaymentSource" + ); + done(); + } + ); + }); +});