Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Hamilton committed May 11, 2020
1 parent 2f05f62 commit ba71bc9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 44 deletions.
5 changes: 0 additions & 5 deletions src/avatar/__tests__/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ describe('Avatar Component', () => {
/>
);

expect(error).toHaveBeenCalledWith(
expect.stringContaining(
'Failed prop type: Invalid prop `size` supplied to `Avatar`'
)
);
expect(component.length).toBe(1);
expect(toJson(component)).toMatchSnapshot();
});
Expand Down
12 changes: 7 additions & 5 deletions src/header/__tests__/Header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Button, ImageBackground } from 'react-native';
import { Button, ImageBackground, View } from 'react-native';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import { create } from 'react-test-renderer';
Expand All @@ -14,7 +14,9 @@ const titleCfg = { text: 'This is a title' };

describe('Header Component', () => {
it('should render without issues', () => {
const component = shallow(<Header theme={theme} />);
const component = shallow(
<Header theme={theme} backgroundImage="image.png" />
);

expect(component.length).toBe(1);
expect(toJson(component)).toMatchSnapshot();
Expand Down Expand Up @@ -96,7 +98,7 @@ describe('Header Component', () => {

expect(
component
.find(ImageBackground)
.find(View)
.first()
.props().style.backgroundColor
).toBe('#aaa');
Expand All @@ -109,7 +111,7 @@ describe('Header Component', () => {

expect(
component
.find(ImageBackground)
.find(View)
.at(0)
.props().style.backgroundColor
).toBe('#ccc');
Expand Down Expand Up @@ -173,7 +175,7 @@ describe('Header Component', () => {

expect(
component
.find(ImageBackground)
.find(View)
.first()
.props().imageStyle
).toEqual({ opacity: 0.1 });
Expand Down
50 changes: 16 additions & 34 deletions src/header/__tests__/__snapshots__/Header.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`Header Component should apply values from theme 1`] = `
<View
accessibilityIgnoresInvertColors={true}
replaceTheme={[Function]}
style={
Object {
"alignItems": "center",
Expand All @@ -16,28 +16,9 @@ exports[`Header Component should apply values from theme 1`] = `
"paddingTop": 20,
}
}
testID="headerContainer"
updateTheme={[Function]}
>
<Image
replaceTheme={[Function]}
style={
Array [
Object {
"bottom": 0,
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
},
Object {
"height": 64,
"width": undefined,
},
undefined,
]
}
testID="headerContainer"
updateTheme={[Function]}
/>
<View
style={
Object {
Expand Down Expand Up @@ -66,7 +47,7 @@ exports[`Header Component should apply values from theme 1`] = `
`;

exports[`Header Component should render center component by passing a config through props 1`] = `
<ImageBackground
<View
style={
Object {
"alignItems": "center",
Expand Down Expand Up @@ -112,11 +93,11 @@ exports[`Header Component should render center component by passing a config thr
}
}
/>
</ImageBackground>
</View>
`;

exports[`Header Component should render left component by passing a component through props 1`] = `
<ImageBackground
<View
style={
Object {
"alignItems": "center",
Expand Down Expand Up @@ -165,11 +146,11 @@ exports[`Header Component should render left component by passing a component th
}
}
/>
</ImageBackground>
</View>
`;

exports[`Header Component should render left component by passing a config through props 1`] = `
<ImageBackground
<View
style={
Object {
"alignItems": "center",
Expand Down Expand Up @@ -215,11 +196,11 @@ exports[`Header Component should render left component by passing a config throu
}
}
/>
</ImageBackground>
</View>
`;

exports[`Header Component should render right component by passing a component through props 1`] = `
<ImageBackground
<View
style={
Object {
"alignItems": "center",
Expand Down Expand Up @@ -268,11 +249,11 @@ exports[`Header Component should render right component by passing a component t
title="Test button"
/>
</Children>
</ImageBackground>
</View>
`;

exports[`Header Component should render right component by passing a config through props 1`] = `
<ImageBackground
<View
style={
Object {
"alignItems": "center",
Expand Down Expand Up @@ -318,7 +299,7 @@ exports[`Header Component should render right component by passing a config thro
>
<Component />
</Children>
</ImageBackground>
</View>
`;

exports[`Header Component should render with backgroundImage 1`] = `
Expand Down Expand Up @@ -375,7 +356,7 @@ exports[`Header Component should render with backgroundImage 1`] = `
`;

exports[`Header Component should render with backgroundImageStyle 1`] = `
<ImageBackground
<View
imageStyle={
Object {
"opacity": 0.1,
Expand Down Expand Up @@ -424,11 +405,12 @@ exports[`Header Component should render with backgroundImageStyle 1`] = `
}
}
/>
</ImageBackground>
</View>
`;

exports[`Header Component should render without issues 1`] = `
<ImageBackground
source="image.png"
style={
Object {
"alignItems": "center",
Expand Down

0 comments on commit ba71bc9

Please sign in to comment.