-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathScenario.js
More file actions
64 lines (53 loc) · 1.8 KB
/
Scenario.js
File metadata and controls
64 lines (53 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* @format
*/
'use strict';
import React, { Component } from "react";
import { Button, Text, View } from "react-native";
import { TestResult } from "./TestCommon";
import { styles } from './Styles'
export class Scenario extends Component {
state = { result: TestResult.NotRun };
constructor(props) {
super(props);
this.state.result = this.props.scenario.result;
this.eventRegistration = this.props.scenario.addListener('completed', this.onCompleted.bind(this));
}
componentWillUnmount() {
this.eventRegistration.remove();
}
onCompleted() {
this.setState({ result: this.props.scenario.result });
}
resultText() {
switch (this.state.result) {
case TestResult.Pass: return 'Pass';
case TestResult.Fail: return 'Fail';
case TestResult.NotRun:
default: return 'In Progress';
}
}
textStyle() {
switch (this.state.result) {
case TestResult.Pass: return styles.passText;
case TestResult.Fail: return styles.failText;
case TestResult.NotRun:
default: return styles.progressText;
}
}
rerunTest() {
this.props.scenario.invoke(this.props.scenario);
}
render() {
return (
<View style={styles.listEntry}>
<Text style={styles.rowItem}>{this.props.scenario.name}</Text>
<Text style={[styles.rowItem, {flex: 1}]}>{this.props.scenario.failureText}</Text>
<Text style={[styles.rowItem, this.textStyle()]}>{this.resultText()}</Text>
<Button style={styles.rowItem} onPress={this.rerunTest.bind(this)} title='Rerun'/>
</View>
);
}
}