@applicaster/zapp-react-native-ui-components
Version:
Applicaster Zapp React Native ui components for the Quick Brick App
81 lines (61 loc) • 2.2 kB
JavaScript
import { Animated } from "react-native";
import { transitionConfig } from "../config";
const animatedValue = new Animated.Value(0.0);
describe("transitionConfig", () => {
it("is a function", () => {
expect(transitionConfig).toBeFunction();
});
it("accepts an Animated.Value as a parameter", () => {
expect(() => {
transitionConfig();
}).toThrowErrorMatchingSnapshot();
expect(() => {
transitionConfig(animatedValue);
}).toMatchSnapshot();
});
describe("returns a push object", () => {
const { push } = transitionConfig(animatedValue);
it("is valid", () => {
expect(push).toMatchSnapshot();
});
it("with duration", () => {
expect(push.duration).toBeDefined();
});
it("with an easing function", () => {
expect(push.easing).toBeFunction();
});
describe("with a from object", () => {
const { from } = push;
it("including interpolated animation in the style", () => {
expect(from.style).toBeDefined();
expect(
from.style.transform[0].translateX._interpolation
).toBeFunction();
expect(from.overlayStyle).toBeDefined();
expect(from.overlayStyle.opacity._interpolation).toBeFunction();
});
});
describe("with a to object", () => {
const { to } = push;
it("including interpolated animation in the style", () => {
expect(to.style).toBeDefined();
expect(to.style.transform[0].translateX._interpolation).toBeFunction();
});
});
});
describe("returns a back object", () => {
const { back } = transitionConfig(animatedValue);
it("is valid", () => {
expect(back).toMatchSnapshot();
});
it("has from and to objects with styles and interpolated animations", () => {
const { from, to } = back;
expect(from.style).toBeDefined();
expect(from.style.transform[0].translateX._interpolation).toBeFunction();
expect(to.overlayStyle).toBeDefined();
expect(to.overlayStyle.opacity._interpolation).toBeFunction();
expect(to.style).toBeDefined();
expect(to.style.transform[0].translateX._interpolation).toBeFunction();
});
});
});