{"size": 1907, "ext": "js", "max_stars_repo_path": "src/index.test.js", "max_stars_repo_name": "Minishlink/easy-lottie-react-native", "max_stars_repo_stars_event_min_datetime": "2017-08-27T23:43:22.000Z", "max_stars_repo_stars_event_max_datetime": "2018-10-30T23:45:08.000Z", "max_issues_repo_path": "src/index.test.js", "max_issues_repo_name": "Minishlink/easy-lottie-react-native", "max_issues_repo_issues_event_min_datetime": "2018-02-01T04:00:57.000Z", "max_issues_repo_issues_event_max_datetime": "2018-08-05T19:25:46.000Z", "max_forks_repo_path": "src/index.test.js", "max_forks_repo_name": "Minishlink/easy-lottie-react-native", "max_forks_repo_forks_event_min_datetime": "2018-08-01T13:10:05.000Z", "max_forks_repo_forks_event_max_datetime": "2018-08-01T13:10:05.000Z"}
{"max_stars_count": 16, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 27.2428571429, "max_line_length": 95, "alphanum_fraction": 0.5836392239}
import 'react-native';
import React from 'react';
import { StyleSheet, Platform } from 'react-native';
import LottieAnimation from './';
import renderer from 'react-test-renderer';

jest.mock('lottie-react-native', () => props => <lottie {...props} />);

const source = {
  nm: 'test',
  fr: 30,
  ip: 25,
  op: 0,
  w: 96,
  h: 48,
};

describe('<LottieAnimation />', () => {
  it('renders correctly by default', () => {
    const tree = renderer.create(<LottieAnimation source={source} />);
    expect(tree.toJSON()).toMatchSnapshot();
  });

  it('renders correctly with a width', () => {
    const tree = renderer.create(<LottieAnimation source={source} style={{ width: 100 }} />);
    expect(tree.toJSON()).toMatchSnapshot();
  });

  it('renders correctly with a height', () => {
    const tree = renderer.create(<LottieAnimation source={source} style={{ height: 40 }} />);
    expect(tree.toJSON()).toMatchSnapshot();
  });

  it('renders correctly with a width in a StyleSheet', () => {
    const styles = StyleSheet.create({ animation: { width: 100 } });
    const tree = renderer.create(<LottieAnimation source={source} style={styles.animation} />);
    expect(tree.toJSON()).toMatchSnapshot();
  });

  it('renders correctly with decimal fr/ip/op in the source on Android', () => {
    Platform.OS = 'android';
    const tree = renderer.create(
      <LottieAnimation
        source={{
          ...source,
          fr: 30.36187,
          op: 0,
          ip: 29.99997,
        }}
      />
    );
    expect(tree.toJSON()).toMatchSnapshot();
    Platform.OS = 'ios';
  });

  it('renders correctly with decimal fr/ip/op in the source on iOS', () => {
    const tree = renderer.create(
      <LottieAnimation
        source={{
          ...source,
          fr: 30.36187,
          op: 0,
          ip: 29.99997,
        }}
      />
    );
    expect(tree.toJSON()).toMatchSnapshot();
  });
});
