Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
teat(ui): modal tests update
  • Loading branch information
32penkin committed Mar 5, 2019
commit 30996443db0c8b4ce1f2a413388488642e5fe701
29 changes: 24 additions & 5 deletions src/framework/theme/component/modal/modalPanel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jest.useFakeTimers();
describe('@modal panel checks', () => {

const showModalTestId: string = '@modal/show';
const hideModalTestId: string = '@modal/hide';
const hideModalTestIdInner: string = '@modal/hide-inner';
const hideModalTestIdOuter: string = '@modal/hide-outer';

interface HooksProps {
componentDidMount?: () => void;
Expand All @@ -28,6 +29,8 @@ describe('@modal panel checks', () => {

class ModalPanelTest extends React.Component<HooksProps> {

private modalId: string = '';

componentDidMount(): void {
this.props.componentDidMount && this.props.componentDidMount();
}
Expand All @@ -37,7 +40,11 @@ describe('@modal panel checks', () => {
}

showModal() {
ModalService.show(<TestModal onRequestClose={() => 1}/>, true);
this.modalId = ModalService.show(<TestModal onRequestClose={() => 1}/>, true);
}

hideModal() {
ModalService.hide(this.modalId);
}

render() {
Expand All @@ -51,6 +58,11 @@ describe('@modal panel checks', () => {
onPress={() => this.showModal()}
testID={showModalTestId}
/>
<Button
title='Hide Modal'
onPress={() => this.hideModal()}
testID={hideModalTestIdOuter}
/>
</ModalPanel>
);
}
Expand All @@ -65,7 +77,7 @@ describe('@modal panel checks', () => {
<Button
title='Close Modal'
onPress={this.props.onCloseModal}
testID={hideModalTestId}
testID={hideModalTestIdInner}
/>
</View>
);
Expand Down Expand Up @@ -101,10 +113,17 @@ describe('@modal panel checks', () => {
expect(componentWillUnmount).toHaveBeenCalled();
});

it('* close modal checking', () => {
it('* close modal checking inner', () => {
const application = render(<ModalPanelTest/>);
fireEvent.press(application.getByTestId(showModalTestId));
fireEvent.press(application.getByTestId(hideModalTestIdInner));
expect(application).toMatchSnapshot();
});

it('* close modal checking outer', () => {
const application = render(<ModalPanelTest/>);
fireEvent.press(application.getByTestId(showModalTestId));
fireEvent.press(application.getByTestId(hideModalTestId));
fireEvent.press(application.getByTestId(hideModalTestIdOuter));
expect(application).toMatchSnapshot();
});

Expand Down
223 changes: 222 additions & 1 deletion src/framework/theme/component/modal/modalPanel.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`@modal panel checks * close modal checking 1`] = `
exports[`@modal panel checks * close modal checking inner 1`] = `
<View
style={
Object {
Expand Down Expand Up @@ -54,6 +54,145 @@ exports[`@modal panel checks * close modal checking 1`] = `
</Text>
</View>
</View>
<View
accessibilityRole="button"
accessibilityStates={Array []}
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
}
testID="@modal/hide-outer"
>
<View
style={
Array [
Object {},
]
}
>
<Text
style={
Array [
Object {
"color": "#007AFF",
"fontSize": 18,
"padding": 8,
"textAlign": "center",
},
]
}
>
Hide Modal
</Text>
</View>
</View>
</View>
`;

exports[`@modal panel checks * close modal checking outer 1`] = `
<View
style={
Object {
"flex": 1,
}
}
>
<View>
<Text>
Modal Panel Test
</Text>
</View>
<View
accessibilityRole="button"
accessibilityStates={Array []}
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
}
testID="@modal/show"
>
<View
style={
Array [
Object {},
]
}
>
<Text
style={
Array [
Object {
"color": "#007AFF",
"fontSize": 18,
"padding": 8,
"textAlign": "center",
},
]
}
>
Open Modal
</Text>
</View>
</View>
<View
accessibilityRole="button"
accessibilityStates={Array []}
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
}
testID="@modal/hide-outer"
>
<View
style={
Array [
Object {},
]
}
>
<Text
style={
Array [
Object {
"color": "#007AFF",
"fontSize": 18,
"padding": 8,
"textAlign": "center",
},
]
}
>
Hide Modal
</Text>
</View>
</View>
</View>
`;

Expand Down Expand Up @@ -111,6 +250,47 @@ exports[`@modal panel checks * modal panel render with props / children checking
</Text>
</View>
</View>
<View
accessibilityRole="button"
accessibilityStates={Array []}
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
}
testID="@modal/hide-outer"
>
<View
style={
Array [
Object {},
]
}
>
<Text
style={
Array [
Object {
"color": "#007AFF",
"fontSize": 18,
"padding": 8,
"textAlign": "center",
},
]
}
>
Hide Modal
</Text>
</View>
</View>
</View>
`;

Expand Down Expand Up @@ -168,5 +348,46 @@ exports[`@modal panel checks * modal panel renders properly 1`] = `
</Text>
</View>
</View>
<View
accessibilityRole="button"
accessibilityStates={Array []}
accessible={true}
isTVSelectable={true}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"opacity": 1,
}
}
testID="@modal/hide-outer"
>
<View
style={
Array [
Object {},
]
}
>
<Text
style={
Array [
Object {
"color": "#007AFF",
"fontSize": 18,
"padding": 8,
"textAlign": "center",
},
]
}
>
Hide Modal
</Text>
</View>
</View>
</View>
`;
Loading