Skip to content

Commit

Permalink
chore: add tests for new components
Browse files Browse the repository at this point in the history
  • Loading branch information
dtjones404 committed Mar 7, 2023
1 parent e367a41 commit b79627d
Show file tree
Hide file tree
Showing 35 changed files with 481 additions and 83 deletions.
14 changes: 12 additions & 2 deletions test/tests/card/amex.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { AmexLogo } from "../../../src";
import { validateSVG } from "../common";
import { AmexLogo, AmexLogoExternalImage } from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("amex logo rendering happy cases", () => {
it("should render the amex logo", () => {
Expand All @@ -15,3 +15,13 @@ describe("amex logo rendering happy cases", () => {
validateSVG(logoHTML);
});
});

describe("AmexLogoExternalImage rendering happy cases", () => {
it("should render the amex logo from CDN", () => {
const logo = <AmexLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});
14 changes: 12 additions & 2 deletions test/tests/card/discover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { DiscoverLogo } from "../../../src";
import { validateSVG } from "../common";
import { DiscoverLogo, DiscoverLogoExternalImage } from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("discover logo rendering happy cases", () => {
it("should render the discover logo", () => {
Expand All @@ -15,3 +15,13 @@ describe("discover logo rendering happy cases", () => {
validateSVG(logoHTML);
});
});

describe("DiscoverLogoExternalImage rendering happy cases", () => {
it("should render the discover logo from CDN", () => {
const logo = <DiscoverLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});
14 changes: 12 additions & 2 deletions test/tests/card/elo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { EloLogo } from "../../../src";
import { validateSVG } from "../common";
import { EloLogo, EloLogoExternalImage } from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("elo logo rendering happy cases", () => {
it("should render the elo logo", () => {
Expand All @@ -15,3 +15,13 @@ describe("elo logo rendering happy cases", () => {
validateSVG(logoHTML);
});
});

describe("EloLogoExternalImage rendering happy cases", () => {
it("should render the elo logo from CDN", () => {
const logo = <EloLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});
14 changes: 12 additions & 2 deletions test/tests/card/hiper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { HiperLogo } from "../../../src";
import { validateSVG } from "../common";
import { HiperLogo, HiperLogoExternalImage } from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("hiper logo rendering happy cases", () => {
it("should render the hiper logo", () => {
Expand All @@ -15,3 +15,13 @@ describe("hiper logo rendering happy cases", () => {
validateSVG(logoHTML);
});
});

describe("HiperLogoExternalImage rendering happy cases", () => {
it("should render the hiper logo from CDN", () => {
const logo = <HiperLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});
14 changes: 12 additions & 2 deletions test/tests/card/jcb.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { JcbLogo } from "../../../src";
import { validateSVG } from "../common";
import { JcbLogo, JcbLogoExternalImage } from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("jcb logo rendering happy cases", () => {
it("should render the jcb logo", () => {
Expand All @@ -15,3 +15,13 @@ describe("jcb logo rendering happy cases", () => {
validateSVG(logoHTML);
});
});

describe("JcbLogoExternalImage rendering happy cases", () => {
it("should render the jcb logo from CDN", () => {
const logo = <JcbLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});
14 changes: 12 additions & 2 deletions test/tests/card/mastercard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { MastercardLogo } from "../../../src";
import { validateSVG } from "../common";
import { MastercardLogo, MastercardLogoExternalImage } from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("mastercard logo rendering happy cases", () => {
it("should render the mastercard logo", () => {
Expand All @@ -15,3 +15,13 @@ describe("mastercard logo rendering happy cases", () => {
validateSVG(logoHTML);
});
});

describe("MastercardLogoExternalImage rendering happy cases", () => {
it("should render the mastercard logo from CDN", () => {
const logo = <MastercardLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});
14 changes: 12 additions & 2 deletions test/tests/card/visa.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { VisaLogo } from "../../../src";
import { validateSVG } from "../common";
import { VisaLogo, VisaLogoExternalImage } from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("visa logo rendering happy cases", () => {
it("should render the visa logo", () => {
Expand All @@ -15,3 +15,13 @@ describe("visa logo rendering happy cases", () => {
validateSVG(logoHTML);
});
});

describe("VisaLogoExternalImage rendering happy cases", () => {
it("should render the visa logo from CDN", () => {
const logo = <VisaLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});
8 changes: 8 additions & 0 deletions test/tests/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export function validateSVG(htmlString: string) {
}
}

export function validateExternalSVG(htmlString: string) {
validateSVG(htmlString);

if (htmlString.indexOf("www.paypalobjects.com") === -1) {
throw new Error(`Expected logo to render from CDN`);
}
}

export function getLocale(
country?: $Values<typeof COUNTRY> = COUNTRY.US,
lang?: $Values<typeof LANG> = LANG.EN
Expand Down
30 changes: 28 additions & 2 deletions test/tests/funding/applepay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { ApplePayLogo, ApplePayMark, LOGO_COLOR } from "../../../src";
import { validateSVG } from "../common";
import {
ApplePayLogo,
ApplePayLogoExternalImage,
ApplePayMark,
ApplePayMarkExternalImage,
LOGO_COLOR,
} from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("Apple Pay logo rendering happy cases", () => {
it("should render the Apple Pay logo", () => {
Expand All @@ -22,3 +28,23 @@ describe("Apple Pay logo rendering happy cases", () => {
validateSVG(markHTML);
});
});

describe("ApplePayLogoExternalImage rendering happy cases", () => {
it("should render the applepay logo from CDN", () => {
const logo = <ApplePayLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});

describe("ApplePayMarkExternalImage rendering happy cases", () => {
it("should render the applepay mark from CDN", () => {
const mark = <ApplePayMarkExternalImage />;

const markHTML = mark.render(html());

validateExternalSVG(markHTML);
});
});
18 changes: 16 additions & 2 deletions test/tests/funding/bancontact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { BancontactLogo, LOGO_COLOR } from "../../../src";
import { validateSVG } from "../common";
import {
BancontactLogo,
BancontactLogoExternalImage,
LOGO_COLOR,
} from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("bancontact logo rendering happy cases", () => {
it("should render the bancontact logo", () => {
Expand All @@ -15,3 +19,13 @@ describe("bancontact logo rendering happy cases", () => {
validateSVG(logoHTML);
});
});

describe("BancontactLogoExternalImage rendering happy cases", () => {
it("should render the bancontact logo from CDN", () => {
const logo = <BancontactLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});
14 changes: 12 additions & 2 deletions test/tests/funding/blik.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { BlikLogo } from "../../../src";
import { validateSVG } from "../common";
import { BlikLogo, BlikLogoExternalImage } from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("blik logo rendering happy cases", () => {
it("should render the payu logo", () => {
Expand All @@ -15,3 +15,13 @@ describe("blik logo rendering happy cases", () => {
validateSVG(logoHTML);
});
});

describe("BlikLogoExternalImage rendering happy cases", () => {
it("should render the blik logo from CDN", () => {
const logo = <BlikLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});
14 changes: 12 additions & 2 deletions test/tests/funding/boleto.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { BoletoLogo } from "../../../src";
import { validateSVG } from "../common";
import { BoletoLogo, BoletoLogoExternalImage } from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("boleto logo rendering happy cases", () => {
it("should render the boleto logo", () => {
Expand All @@ -15,3 +15,13 @@ describe("boleto logo rendering happy cases", () => {
validateSVG(logoHTML);
});
});

describe("BoletoLogoExternalImage rendering happy cases", () => {
it("should render the boleto logo from CDN", () => {
const logo = <BoletoLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});
31 changes: 29 additions & 2 deletions test/tests/funding/credit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
import { node, html } from "@krakenjs/jsx-pragmatic/src";
import { COUNTRY, LANG } from "@paypal/sdk-constants/src";

import { CreditLogo, LOGO_COLOR } from "../../../src";
import { validateSVG, getLocale } from "../common";
import {
CreditLogo,
CreditLogoExternalImage,
CreditMarkExternalImage,
LOGO_COLOR,
} from "../../../src";
import { validateSVG, getLocale, validateExternalSVG } from "../common";

describe("credit logo rendering happy cases", () => {
it("should render the credit logo", () => {
Expand Down Expand Up @@ -44,6 +49,28 @@ describe("credit logo rendering happy cases", () => {
});
});

describe("CreditLogoExternalImage rendering happy cases", () => {
it("should render the credit logo from CDN", () => {
const logo = (
<CreditLogoExternalImage locale={getLocale(COUNTRY.US, LANG.EN)} />
);

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});

describe("CreditMarkExternalImage rendering happy cases", () => {
it("should render the credit mark from CDN", () => {
const mark = <CreditMarkExternalImage />;

const markHTML = mark.render(html());

validateExternalSVG(markHTML);
});
});

describe("credit logo rendering error cases", () => {
it("should error while rendering the credit logo with no locale passed", () => {
let error;
Expand Down
14 changes: 12 additions & 2 deletions test/tests/funding/eps.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import { node, html } from "@krakenjs/jsx-pragmatic/src";

import { EpsLogo, LOGO_COLOR } from "../../../src";
import { validateSVG } from "../common";
import { EpsLogo, EpsLogoExternalImage, LOGO_COLOR } from "../../../src";
import { validateExternalSVG, validateSVG } from "../common";

describe("eps logo rendering happy cases", () => {
it("should render the eps logo", () => {
Expand All @@ -15,3 +15,13 @@ describe("eps logo rendering happy cases", () => {
validateSVG(logoHTML);
});
});

describe("EpsLogoExternalImage rendering happy cases", () => {
it("should render the eps logo from CDN", () => {
const logo = <EpsLogoExternalImage />;

const logoHTML = logo.render(html());

validateExternalSVG(logoHTML);
});
});
Loading

0 comments on commit b79627d

Please sign in to comment.