@qite/tide-client
Version:
Frontend client for Tide
62 lines (56 loc) • 1.55 kB
text/typescript
import {
TideClientConfig,
WebContactFormRequest,
WebContactHasTagRequest,
} from "../src/types";
import { contactForm, contactHasTag } from "../src/utils/web-contact-client";
import jestFetchMock from "jest-fetch-mock";
describe("webContactClient", (): void => {
beforeAll(() => {
jestFetchMock.enableMocks();
});
beforeEach(() => {
jestFetchMock.mockResponse((req) => {
switch (req.url) {
case "https://mock.com/api/web/contact/contact-form":
return Promise.resolve("");
case "https://mock.com/api/web/contact/has-tag":
return Promise.resolve("");
default:
return Promise.reject();
}
});
});
// Just test if the call is succeeding
test("contactForm", () => {
const config: TideClientConfig = {
host: "https://mock.com",
apiKey: "key123",
};
const request: WebContactFormRequest = {
firstName: "Test",
lastName: "Qite",
email: "test@qite.be",
officeId: 1,
languageCode: "nl-BE",
message: "Test",
};
return contactForm(config, request).then((data) => {
expect(data).toBeTruthy();
});
});
// Just test if the call is succeeding
test("contactHasTag", () => {
const config: TideClientConfig = {
host: "https://mock.com",
apiKey: "key123",
};
const request: WebContactHasTagRequest = {
email: "test@qite.be",
tag: 1,
};
return contactHasTag(config, request).then((data) => {
expect(data).toBeTruthy();
});
});
});