Skip to content

Commit

Permalink
Add missing ec-form tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phieronymus committed Dec 1, 2020
1 parent 52e025a commit f140c15
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/specs/ec-forms.specs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { expect } from "chai";
import fetchMock from "fetch-mock";
import { v4 as uuid } from "uuid";

import { RestAPI } from "../../src/api/RestAPI";
import { ECForms } from "../../src/resources/ECForms";
import { generateFixture as generateCheckoutInfo } from "../fixtures/checkout-info";
import { testEndpoint } from "../utils";
import { pathToRegexMatcher } from "../utils/routes";

describe("EC Forms", () => {
let api: RestAPI;
let ecForms: ECForms;

const recordData = generateCheckoutInfo();
const recordPathMatcher = pathToRegexMatcher(`${testEndpoint}/forms/:id`);

beforeEach(() => {
api = new RestAPI({ endpoint: testEndpoint });
ecForms = new ECForms(api);
});

afterEach(() => {
fetchMock.restore();
});

context("GET /forms/:id", () => {
it("should get response", async () => {
fetchMock.getOnce(recordPathMatcher, {
status: 200,
body: recordData,
headers: { "Content-Type": "application/json" },
});

await expect(ecForms.get(uuid())).to.eventually.eql(recordData);
});
});
});

0 comments on commit f140c15

Please sign in to comment.