UNPKG

@applicaster/zapp-react-native-ui-components

Version:

Applicaster Zapp React Native ui components for the Quick Brick App

74 lines (63 loc) 1.68 kB
jest.mock( "@applicaster/zapp-react-native-utils/reactUtils/createContext", () => ({ createContext: jest.fn(() => ({ Consumer: jest.fn(), Provider: jest.fn(), withConsumer: jest.fn(), withProvider: jest.fn(), })), }) ); const { DISPLAY_STATES, stateValidator, DisplayStateContext, } = require("../index"); const { createContext, } = require("@applicaster/zapp-react-native-utils/reactUtils/createContext"); describe("DISPLAY_STATES", () => { it("matches the snapshot", () => { expect(DISPLAY_STATES).toMatchSnapshot(); }); }); describe("stateValidator", () => { it("returns false if the property is not `displayState`", () => { expect(stateValidator({ property: "anything" })).toBe(false); }); it("returns false if the value is not in DISPLAY_STATES", () => { expect(stateValidator({ value: "anything" })).toBe(false); }); it("returns true otherwise", () => { expect( stateValidator({ property: "displayState", value: DISPLAY_STATES.DISCOVERY, }) ).toBe(true); expect( stateValidator({ property: "displayState", value: DISPLAY_STATES.CONTENT, }) ).toBe(true); expect( stateValidator({ property: "displayState", value: DISPLAY_STATES.CONTROLS, }) ).toBe(true); }); }); describe("DisplayStateContext", () => { it("calls the context creator", () => { expect(createContext).toHaveBeenCalledWith( { displayState: DISPLAY_STATES.DISCOVERY }, stateValidator ); }); it("has the correct properties", () => { expect(DisplayStateContext).toMatchSnapshot(); }); });