-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include unit test cases for atoms, molecules and organisms
- Loading branch information
Sameeha Rahman
authored and
Sameeha Rahman
committed
Apr 1, 2019
1 parent
3976e00
commit bc4e89e
Showing
82 changed files
with
17,979 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
Oops, something went wrong.