-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathreact_component_test.dart
101 lines (95 loc) · 3.69 KB
/
react_component_test.dart
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// ignore_for_file: deprecated_member_use_from_same_package
@TestOn('browser')
import 'package:react/react.dart';
import 'package:test/test.dart';
main() {
group('Component2', () {
late Component2 component;
setUpAll(() {
component = MyComponent();
});
group('throws when unsupported lifecycle methods are called (e.g., via super-calls)', () {
test('getInitialState', () {
expect(() => component.getInitialState(), throwsUnsupportedError);
});
test('getDefaultProps', () {
expect(() => component.getDefaultProps(), throwsUnsupportedError);
});
test('componentWillMount', () {
expect(() => component.componentWillMount(), throwsUnsupportedError);
});
test('componentWillReceiveProps', () {
expect(() => component.componentWillReceiveProps({}), throwsUnsupportedError);
});
test('componentWillUpdate', () {
expect(() => component.componentWillUpdate({}, {}), throwsUnsupportedError);
});
test('getChildContext', () {
expect(() => component.getChildContext(), throwsUnsupportedError);
});
test('shouldComponentUpdateWithContext', () {
expect(() => component.shouldComponentUpdateWithContext({}, {}, null), throwsUnsupportedError);
});
test('componentWillUpdateWithContext', () {
expect(() => component.componentWillUpdateWithContext({}, {}, null), throwsUnsupportedError);
});
test('componentWillReceivePropsWithContext', () {
expect(() => component.componentWillReceivePropsWithContext({}, null), throwsUnsupportedError);
});
});
group('throws when unsupported members inherited from Component are used', () {
test('replaceState', () {
expect(() => component.replaceState(null), throwsUnsupportedError);
});
test('childContextKeys getter', () {
expect(() => component.childContextKeys, throwsUnsupportedError);
});
test('contextKeys getter', () {
expect(() => component.contextKeys, throwsUnsupportedError);
});
test('initComponentInternal', () {
expect(() => component.initComponentInternal({}, () {}), throwsUnsupportedError);
});
test('initStateInternal', () {
expect(() => component.initStateInternal(), throwsUnsupportedError);
});
test('nextContext getter', () {
expect(() => component.nextContext, throwsUnsupportedError);
});
test('nextContext setter', () {
expect(() => component.nextContext = null, throwsUnsupportedError);
});
test('prevContext getter', () {
expect(() => component.prevContext, throwsUnsupportedError);
});
test('prevContext setter', () {
expect(() => component.prevContext = null, throwsUnsupportedError);
});
test('prevState getter', () {
expect(() => component.prevState, throwsUnsupportedError);
});
test('nextState getter', () {
expect(() => component.nextState, throwsUnsupportedError);
});
test('nextProps getter', () {
expect(() => component.nextProps, throwsUnsupportedError);
});
test('transferComponentState', () {
expect(() => component.transferComponentState(), throwsUnsupportedError);
});
test('ref getter', () {
expect(() => component.ref, throwsUnsupportedError);
});
test('setStateCallbacks getter', () {
expect(() => component.setStateCallbacks, throwsUnsupportedError);
});
test('transactionalSetStateCallbacks getter', () {
expect(() => component.transactionalSetStateCallbacks, throwsUnsupportedError);
});
});
});
}
class MyComponent extends Component2 {
@override
render() => null;
}