@applicaster/zapp-react-native-utils
Version:
Applicaster Zapp React Native utilities package
99 lines (82 loc) • 2.34 kB
text/typescript
import { isParentFocusEqual } from "..";
describe("isParentFocusEqual", () => {
const nextFocusUp = {} as unknown as TouchableAndroid;
const nextFocusDown = {} as unknown as TouchableAndroid;
const nextFocusRight = {} as unknown as TouchableAndroid;
const nextFocusLeft = {} as unknown as TouchableAndroid;
it("equals", () => {
const prevParentFocus = {
nextFocusUp,
nextFocusDown,
nextFocusRight: undefined,
nextFocusLeft: undefined,
};
const nextParentFocus = {
nextFocusUp,
nextFocusDown,
nextFocusRight: undefined,
nextFocusLeft: undefined,
};
expect(isParentFocusEqual(prevParentFocus, nextParentFocus)).toBe(true);
});
it("equals", () => {
const prevParentFocus = {
nextFocusUp: undefined,
nextFocusDown: undefined,
nextFocusRight: undefined,
nextFocusLeft: undefined,
};
const nextParentFocus = {
nextFocusUp: undefined,
nextFocusDown: undefined,
nextFocusRight: undefined,
nextFocusLeft: undefined,
};
expect(isParentFocusEqual(prevParentFocus, nextParentFocus)).toBe(true);
});
it("equals", () => {
const prevParentFocus = {
nextFocusUp: undefined,
nextFocusDown: undefined,
nextFocusRight: undefined,
nextFocusLeft: null,
};
const nextParentFocus = {
nextFocusUp: undefined,
nextFocusDown: undefined,
nextFocusRight: undefined,
nextFocusLeft: null,
};
expect(isParentFocusEqual(prevParentFocus, nextParentFocus)).toBe(true);
});
it("not equals", () => {
const prevParentFocus = {
nextFocusUp,
nextFocusDown,
nextFocusRight: undefined,
nextFocusLeft: undefined,
};
const nextParentFocus = {
nextFocusUp,
nextFocusDown,
nextFocusRight,
nextFocusLeft,
};
expect(isParentFocusEqual(prevParentFocus, nextParentFocus)).toBe(false);
});
it("not equals", () => {
const prevParentFocus = {
nextFocusUp,
nextFocusDown,
nextFocusRight,
nextFocusLeft,
};
const nextParentFocus = {
nextFocusUp,
nextFocusDown,
nextFocusRight: nextFocusLeft,
nextFocusLeft: nextFocusRight,
};
expect(isParentFocusEqual(prevParentFocus, nextParentFocus)).toBe(false);
});
});