@@ -41,28 +41,25 @@ void main() {
41
41
test ('it sends the login message' , () async {
42
42
when (socket.connect ()).thenAnswer ((_) => new Future .value ());
43
43
when (socket.id).thenReturn ('testId' );
44
- when (socket.emit ("login" , "master" , captureAny))
45
- .thenAnswer ((Invocation i) {
44
+ when (socket.emit ("login" , "master" , captureAny)).thenAnswer ((Invocation i) {
46
45
Function fn = i.positionalArguments[2 ];
47
46
fn ('testChannel' , 'err' , 'data' );
48
47
});
49
48
await devtools.connect ();
50
49
verify (socket.emit ("login" , "master" , captureAny));
51
50
});
52
51
test ('it sends the start message message' , () async {
53
- when (socket.emit ("login" , "master" , captureAny))
54
- .thenAnswer ((Invocation i) {
52
+ when (socket.emit ("login" , "master" , captureAny)).thenAnswer ((Invocation i) {
55
53
Function fn = i.positionalArguments[2 ];
56
54
fn ('testChannel' , 'err' , 'data' );
57
55
});
58
56
when (socket.id).thenReturn ('testId' );
59
57
connectResponse = await devtools.connect ();
60
- verify (socket. emit ( "log" ,
61
- {'type' : "START" , 'id' : 'testId' , 'name' : 'flutter' }, captureAny));
58
+ verify (
59
+ socket. emit ( "log" , {'type' : "START" , 'id' : 'testId' , 'name' : 'flutter' }, captureAny));
62
60
});
63
61
test ('it sends the state' , () async {
64
- when (socket.emit ("login" , "master" , captureAny))
65
- .thenAnswer ((Invocation i) {
62
+ when (socket.emit ("login" , "master" , captureAny)).thenAnswer ((Invocation i) {
66
63
Function fn = i.positionalArguments[2 ];
67
64
fn ('testChannel' , 'err' , 'data' );
68
65
});
@@ -71,8 +68,8 @@ void main() {
71
68
when (store.state).thenReturn ('TEST STATE' );
72
69
devtools.store = store;
73
70
connectResponse = await devtools.connect ();
74
- verify (socket. emit ( "log" ,
75
- {'type' : "START" , 'id' : 'testId' , 'name' : 'flutter' }, captureAny));
71
+ verify (
72
+ socket. emit ( "log" , {'type' : "START" , 'id' : 'testId' , 'name' : 'flutter' }, captureAny));
76
73
verify (socket.emit (
77
74
"log" ,
78
75
{
@@ -95,8 +92,7 @@ void main() {
95
92
store = new MockStore ();
96
93
when (store.state).thenReturn ({'state' : 42 });
97
94
socket = new MockSocket ();
98
- when (socket.emit ("login" , "master" , captureAny))
99
- .thenAnswer ((Invocation i) {
95
+ when (socket.emit ("login" , "master" , captureAny)).thenAnswer ((Invocation i) {
100
96
Function fn = i.positionalArguments[2 ];
101
97
fn ('testChannel' , 'err' , 'data' );
102
98
});
@@ -105,7 +101,22 @@ void main() {
105
101
devtools = RemoteDevToolsMiddleware ('example.com' , socket: socket);
106
102
await devtools.connect ();
107
103
});
104
+ test ('nothing sent if status is not started' , () {
105
+ devtools.call (store, TestActions .SomeAction , next.next);
106
+ verifyNever (socket.emit (
107
+ 'log' ,
108
+ {
109
+ 'type' : 'ACTION' ,
110
+ 'id' : 'testId' ,
111
+ 'name' : 'flutter' ,
112
+ 'payload' : '{"state":42}' ,
113
+ 'action' : '{"type":"TestActions.SomeAction"}' ,
114
+ 'nextActionId' : null
115
+ },
116
+ captureAny));
117
+ });
108
118
test ('the action and state are sent' , () {
119
+ devtools.status = RemoteDevToolsStatus .started;
109
120
devtools.call (store, TestActions .SomeAction , next.next);
110
121
verify (socket.emit (
111
122
'log' ,
@@ -132,8 +143,7 @@ void main() {
132
143
store = new MockStore ();
133
144
when (store.state).thenReturn ({'state' : 42 });
134
145
socket = new MockSocket ();
135
- when (socket.emit ("login" , "master" , captureAny))
136
- .thenAnswer ((Invocation i) {
146
+ when (socket.emit ("login" , "master" , captureAny)).thenAnswer ((Invocation i) {
137
147
Function fn = i.positionalArguments[2 ];
138
148
fn ('testChannel' , 'err' , 'data' );
139
149
});
@@ -143,6 +153,14 @@ void main() {
143
153
devtools.store = store;
144
154
await devtools.connect ();
145
155
});
156
+ test ('START response sets status to STARTED' , () {
157
+ var remoteData = {
158
+ 'type' : 'START' ,
159
+ };
160
+ expect (devtools.status, RemoteDevToolsStatus .starting);
161
+ devtools.handleEventFromRemote (remoteData);
162
+ expect (devtools.status, RemoteDevToolsStatus .started);
163
+ });
146
164
test ('handles time travel' , () {
147
165
var remoteData = {
148
166
'type' : 'DISPATCH' ,
@@ -157,8 +175,7 @@ void main() {
157
175
'type' : 'DISPATCH' ,
158
176
'action' : {'type' : 'JUMP_TO_STATE' , 'index' : 4 }
159
177
};
160
- expect (
161
- () => devtools.handleEventFromRemote (remoteData), returnsNormally);
178
+ expect (() => devtools.handleEventFromRemote (remoteData), returnsNormally);
162
179
});
163
180
});
164
181
});
0 commit comments