shellphone.app/app/pages/index.test.tsx

40 lines
1.2 KiB
TypeScript
Raw Normal View History

import { render } from "../../test/utils";
import Home from "./index";
import useCurrentCustomer from "../core/hooks/use-current-customer";
2021-07-31 14:33:18 +00:00
jest.mock("../core/hooks/use-current-customer");
const mockUseCurrentCustomer = useCurrentCustomer as jest.MockedFunction<typeof useCurrentCustomer>;
2021-07-31 14:33:18 +00:00
test.skip("renders blitz documentation link", () => {
// This is an example of how to ensure a specific item is in the document
// But it's disabled by default (by test.skip) so the test doesn't fail
// when you remove the the default content from the page
// This is an example on how to mock api hooks when testing
mockUseCurrentCustomer.mockReturnValue({
customer: {
id: uuidv4(),
encryptionKey: "",
accountSid: null,
authToken: null,
twimlAppSid: null,
paddleCustomerId: null,
paddleSubscriptionId: null,
user: {} as any,
},
hasCompletedOnboarding: false,
});
2021-07-31 14:33:18 +00:00
const { getByText } = render(<Home />);
const linkElement = getByText(/Documentation/i);
expect(linkElement).toBeInTheDocument();
});
2021-07-31 14:33:18 +00:00
function uuidv4() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
const r = (Math.random() * 16) | 0,
v = c == "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
2021-07-31 14:33:18 +00:00
}