@applicaster/zapp-react-native-ui-components
Version:
Applicaster Zapp React Native ui components for the Quick Brick App
96 lines (76 loc) • 2.73 kB
JavaScript
import * as React from "react";
import { View } from "react-native";
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
import { testCellStyle } from "./TestCellStyle";
import { singleView } from "./SingleView";
import { entry } from "./testEntry";
import { singleElement } from "./testElements";
jest.mock(
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
() => ({
useRoute: jest.fn(() => ({ screenData: { id: "test" } })),
})
);
jest.mock(
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
() => ({
useIsScreenActive: jest.fn(() => true),
})
);
jest.mock("@applicaster/zapp-react-native-utils/screenState", () => ({
useScreenState: jest.fn(() => ({
get: jest.fn(),
setSelectedEntry: jest.fn(),
})),
}));
const { masterCellBuilder } = require("../index");
const mock_singleElement = singleElement;
describe("masterCellBuilder", () => {
describe("when using default options", () => {
const MasterCell = masterCellBuilder({ cellConfiguration: testCellStyle });
it("renders correctly", () => {
const wrapper = renderWithProviders(
<View testID="master-cell">
<MasterCell item={entry} />
</View>
);
expect(wrapper.getByTestId("master-cell").children[0]).toBeDefined();
});
});
describe.skip("when using custom containerStyle", () => {
const MasterCell = masterCellBuilder({
cellConfiguration: singleView,
containerStyle: { backgroundColor: "black" },
});
it("renders correctly", () => {
renderWithProviders(<MasterCell item={entry} />);
// TODO define the test need
});
});
describe("when using a custom data adapter", () => {
const dataAdapter = jest.fn(() => () => mock_singleElement);
const MasterCell = masterCellBuilder({
cellConfiguration: singleView,
dataAdapter,
});
it("renders correctly", () => {
renderWithProviders(<MasterCell item={entry} />);
// TODO define the test need
expect(dataAdapter).toHaveBeenCalledWith(singleView);
});
});
describe.skip("when using custom default components", () => {
// the collapsable prop is added here to easily check from the snapshot that the mock
// component is being used instead of the default one
const CustomView = jest.fn((props) => <View {...props} collapsable />);
const components = { View: CustomView };
const MasterCell = masterCellBuilder({
cellConfiguration: singleView,
components,
});
it("renders correctly", () => {
renderWithProviders(<MasterCell item={entry} />);
// TODO define the test need
});
});
});