Nualiian
2/15/2018 - 9:48 AM

Card.test.js

import "react-native";
import React from "react";
import { Text } from "react-native";

import renderer from "react-test-renderer";

import Card from "components/Card";

const mockCustomContainerStyles = { width: 200 };

test("renders correctly with no props passed", () => {
  const wrapper = renderer.create(<Card />).toJSON();
  expect(wrapper).toMatchSnapshot();
});

test("renders correctly with one child passed", () => {
  const wrapper = renderer
    .create(
      <Card>
        <Text>Hello!</Text>
      </Card>
    )
    .toJSON();
  expect(wrapper).toMatchSnapshot();
});

test("renders correctly with more children passed", () => {
  const wrapper = renderer
    .create(
      <Card>
        <Text>Hello!</Text>
        <Text>World!</Text>
      </Card>
    )
    .toJSON();
  expect(wrapper).toMatchSnapshot();
});

test("renders correctly with all props passed", () => {
  const wrapper = renderer.create(
    <Card customContainerStyles={mockCustomContainerStyles}>
      <Text>Hello!</Text>
      <Text>World!</Text>
    </Card>
  );
});