@applicaster/zapp-react-native-ui-components
Version:
Applicaster Zapp React Native ui components for the Quick Brick App
35 lines (28 loc) • 1 kB
JavaScript
import * as FOCUS_EVENTS from "@applicaster/zapp-react-native-utils/appUtils/focusManager/events";
const mockInvokeHandler = jest.fn();
jest.mock("@applicaster/zapp-react-native-utils/appUtils/focusManager", () => ({
focusManager: {
invokeHandler: mockInvokeHandler,
},
}));
const { BaseFocusable } = require("../index.ios");
describe("BaseFocusable", () => {
// arrange
const focusable = {};
const scrollDirection = {};
const onFocus = jest.fn();
const instance = new BaseFocusable({ onFocus });
it("should invoke focus event when onFocus is called", () => {
const spyOnSetFocusedState = jest.spyOn(instance, "setFocusedState");
// act
instance.onFocus(focusable, scrollDirection);
// assert
expect(spyOnSetFocusedState).toHaveBeenCalledWith(true);
expect(onFocus).toHaveBeenCalledWith(focusable, scrollDirection);
expect(mockInvokeHandler).toHaveBeenCalledWith(
FOCUS_EVENTS.FOCUS,
focusable,
scrollDirection
);
});
});