Skip to content

Commit

Permalink
Include unit test cases for atoms, molecules and organisms
Browse files Browse the repository at this point in the history
  • Loading branch information
Sameeha Rahman authored and Sameeha Rahman committed Apr 1, 2019
1 parent 3976e00 commit bc4e89e
Show file tree
Hide file tree
Showing 82 changed files with 17,979 additions and 3 deletions.
101 changes: 101 additions & 0 deletions __tests__/atoms/Button.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import "react-native";
import React from "react";
import renderer from "react-test-renderer";
import { Button } from "../../src/atoms/Button";
import { Text } from "../../src/atoms/Text";
import { Icon } from "../../src/atoms/Icon";

jest.mock("Platform", () => {
const Platform = require.requireActual("Platform");
Platform.OS = "android";
return Platform;
});

it("renders regular button", () => {
const tree = renderer
.create(
<Button>
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders icon button", () => {
const tree = renderer
.create(
<Button>
<Icon name="heart" />
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders rounded button", () => {
const tree = renderer
.create(
<Button rounded>
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders transparent button", () => {
const tree = renderer
.create(
<Button transparent>
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders block button", () => {
const tree = renderer
.create(
<Button block>
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders outline button", () => {
const tree = renderer
.create(
<Button outline>
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders small button", () => {
const tree = renderer
.create(
<Button size="small">
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders large button", () => {
const tree = renderer
.create(
<Button size="large">
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});
101 changes: 101 additions & 0 deletions __tests__/atoms/Button.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import "react-native";
import React from "react";
import renderer from "react-test-renderer";
import { Button } from "../../src/atoms/Button";
import { Text } from "../../src/atoms/Text";
import { Icon } from "../../src/atoms/Icon";

jest.mock("Platform", () => {
const Platform = require.requireActual("Platform");
Platform.OS = "ios";
return Platform;
});

it("renders regular button", () => {
const tree = renderer
.create(
<Button>
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders icon button", () => {
const tree = renderer
.create(
<Button>
<Icon name="heart" />
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders rounded button", () => {
const tree = renderer
.create(
<Button rounded>
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders transparent button", () => {
const tree = renderer
.create(
<Button transparent>
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders block button", () => {
const tree = renderer
.create(
<Button block>
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders outline button", () => {
const tree = renderer
.create(
<Button outline>
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders small button", () => {
const tree = renderer
.create(
<Button size="small">
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders large button", () => {
const tree = renderer
.create(
<Button size="large">
<Text>Click Me</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});
27 changes: 27 additions & 0 deletions __tests__/atoms/DatePicker.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import "react-native";
import React from "react";
import renderer from "react-test-renderer";
import { DatePicker } from "../../src/atoms/DatePicker";

jest.mock("Platform", () => {
const Platform = require.requireActual("Platform");
Platform.OS = "android";
return Platform;
});

it("renders regular DatePicker", () => {
const tree = renderer.create(<DatePicker />).toJSON();
expect(tree).toMatchSnapshot();
});

it("renders colored DatePicker", () => {
const tree = renderer.create(<DatePicker color="red" />).toJSON();
expect(tree).toMatchSnapshot();
});

it("renders DatePicker with placeholder", () => {
const tree = renderer
.create(<DatePicker placeholder="placeholder" />)
.toJSON();
expect(tree).toMatchSnapshot();
});
38 changes: 38 additions & 0 deletions __tests__/atoms/DatePicker.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import "react-native";
import React from "react";
import renderer from "react-test-renderer";
import { DatePicker } from "../../src/atoms/DatePicker";

jest.mock("Platform", () => {
const Platform = require.requireActual("Platform");
Platform.OS = "ios";
return Platform;
});

it("renders regular DatePicker", () => {
const tree = renderer
.create(<DatePicker defaultDate={new Date(1554104240475)} />)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders colored DatePicker", () => {
const tree = renderer
.create(
<DatePicker color="red" defaultDate={new Date(1554104240475)} />
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("renders DatePicker with placeholder", () => {
const tree = renderer
.create(
<DatePicker
placeholder="placeholder"
defaultDate={new Date(1554104240475)}
/>
)
.toJSON();
expect(tree).toMatchSnapshot();
});
20 changes: 20 additions & 0 deletions __tests__/atoms/Icon.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import "react-native";
import React from "react";
import renderer from "react-test-renderer";
import { Icon } from "../../src/atoms/Icon";

jest.mock("Platform", () => {
const Platform = require.requireActual("Platform");
Platform.OS = "android";
return Platform;
});

it("renders regular icon", () => {
const tree = renderer.create(<Icon name="heart" />).toJSON();
expect(tree).toMatchSnapshot();
});

it("renders colored icon", () => {
const tree = renderer.create(<Icon name="heart" color="red" />).toJSON();
expect(tree).toMatchSnapshot();
});
20 changes: 20 additions & 0 deletions __tests__/atoms/Icon.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import "react-native";
import React from "react";
import renderer from "react-test-renderer";
import { Icon } from "../../src/atoms/Icon";

jest.mock("Platform", () => {
const Platform = require.requireActual("Platform");
Platform.OS = "ios";
return Platform;
});

it("renders regular icon", () => {
const tree = renderer.create(<Icon name="heart" />).toJSON();
expect(tree).toMatchSnapshot();
});

it("renders colored icon", () => {
const tree = renderer.create(<Icon name="heart" color="red" />).toJSON();
expect(tree).toMatchSnapshot();
});
25 changes: 25 additions & 0 deletions __tests__/atoms/Input.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import "react-native";
import React from "react";
import renderer from "react-test-renderer";
import { Input } from "../../src/atoms/Input";

jest.mock("Platform", () => {
const Platform = require.requireActual("Platform");
Platform.OS = "android";
return Platform;
});

it("renders regular Input", () => {
const tree = renderer.create(<Input />).toJSON();
expect(tree).toMatchSnapshot();
});

it("renders colored Input", () => {
const tree = renderer.create(<Input color="red" />).toJSON();
expect(tree).toMatchSnapshot();
});

it("renders Input with placeholder", () => {
const tree = renderer.create(<Input placeholder="placeholder" />).toJSON();
expect(tree).toMatchSnapshot();
});
25 changes: 25 additions & 0 deletions __tests__/atoms/Input.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import "react-native";
import React from "react";
import renderer from "react-test-renderer";
import { Input } from "../../src/atoms/Input";

jest.mock("Platform", () => {
const Platform = require.requireActual("Platform");
Platform.OS = "ios";
return Platform;
});

it("renders regular Input", () => {
const tree = renderer.create(<Input />).toJSON();
expect(tree).toMatchSnapshot();
});

it("renders colored Input", () => {
const tree = renderer.create(<Input color="red" />).toJSON();
expect(tree).toMatchSnapshot();
});

it("renders Input with placeholder", () => {
const tree = renderer.create(<Input placeholder="placeholder" />).toJSON();
expect(tree).toMatchSnapshot();
});
Loading

0 comments on commit bc4e89e

Please sign in to comment.