@@ -42,6 +42,10 @@ void main() {
42
42
test ('it sends the login message' , () async {
43
43
when (socket.connect ()).thenAnswer ((_) => new Future .value ());
44
44
when (socket.id).thenReturn ('testId' );
45
+ when (socket.on ("data" , captureAny)).thenAnswer ((Invocation i) {
46
+ Function fn = i.positionalArguments[1 ];
47
+ fn ("name" , {'type' : 'START' });
48
+ });
45
49
when (socket.emit ("login" , "master" , captureAny)).thenAnswer ((Invocation i) {
46
50
Function fn = i.positionalArguments[2 ];
47
51
fn ('testChannel' , 'err' , 'data' );
@@ -55,15 +59,37 @@ void main() {
55
59
fn ('testChannel' , 'err' , 'data' );
56
60
});
57
61
when (socket.id).thenReturn ('testId' );
62
+ when (socket.on ("data" , captureAny)).thenAnswer ((Invocation i) {
63
+ Function fn = i.positionalArguments[1 ];
64
+ fn ("name" , {'type' : 'START' });
65
+ });
58
66
connectResponse = await devtools.connect ();
59
- verify (
60
- socket.emit ("log" , {'type' : "START" , 'id' : 'testId' , 'name' : 'flutter' }, captureAny));
67
+ verify (socket.emit ("log" , {'type' : "START" , 'id' : 'testId' , 'name' : 'flutter' }, captureAny));
68
+ });
69
+ test ('it is in STARTED state' , () async {
70
+ when (socket.connect ()).thenAnswer ((_) => new Future .value ());
71
+ when (socket.id).thenReturn ('testId' );
72
+ when (socket.on ("data" , captureAny)).thenAnswer ((Invocation i) {
73
+ Function fn = i.positionalArguments[1 ];
74
+ fn ("name" , {'type' : 'START' });
75
+ });
76
+ when (socket.emit ("login" , "master" , captureAny))
77
+ .thenAnswer ((Invocation i) {
78
+ Function fn = i.positionalArguments[2 ];
79
+ fn ('testChannel' , 'err' , 'data' );
80
+ });
81
+ await devtools.connect ();
82
+ expect (devtools.status, RemoteDevToolsStatus .started);
61
83
});
62
84
test ('it sends the state' , () async {
63
85
when (socket.emit ("login" , "master" , captureAny)).thenAnswer ((Invocation i) {
64
86
Function fn = i.positionalArguments[2 ];
65
87
fn ('testChannel' , 'err' , 'data' );
66
88
});
89
+ when (socket.on ("data" , captureAny)).thenAnswer ((Invocation i) {
90
+ Function fn = i.positionalArguments[1 ];
91
+ fn ("name" , {'type' : 'START' });
92
+ });
67
93
when (socket.id).thenReturn ('testId' );
68
94
var store = MockStore ();
69
95
when (store.state).thenReturn ('TEST STATE' );
@@ -97,12 +123,17 @@ void main() {
97
123
Function fn = i.positionalArguments[2 ];
98
124
fn ('testChannel' , 'err' , 'data' );
99
125
});
126
+ when (socket.on ("data" , captureAny)).thenAnswer ((Invocation i) {
127
+ Function fn = i.positionalArguments[1 ];
128
+ return fn ("name" , {'type' : 'START' });
129
+ });
100
130
when (socket.id).thenReturn ('testId' );
101
131
when (socket.connect ()).thenAnswer ((_) => new Future .value ());
102
132
devtools = RemoteDevToolsMiddleware ('example.com' , socket: socket);
103
133
await devtools.connect ();
104
134
});
105
135
test ('nothing sent if status is not started' , () {
136
+ devtools.status = RemoteDevToolsStatus .starting;
106
137
devtools.call (store, TestActions .SomeAction , next.next);
107
138
verifyNever (socket.emit (
108
139
'log' ,
@@ -148,20 +179,16 @@ void main() {
148
179
Function fn = i.positionalArguments[2 ];
149
180
fn ('testChannel' , 'err' , 'data' );
150
181
});
182
+ when (socket.on ("data" , captureAny)).thenAnswer ((Invocation i) {
183
+ Function fn = i.positionalArguments[1 ];
184
+ return fn ("name" , {'type' : 'START' });
185
+ });
151
186
when (socket.id).thenReturn ('testId' );
152
187
when (socket.connect ()).thenAnswer ((_) => new Future .value ());
153
188
devtools = RemoteDevToolsMiddleware ('example.com' , socket: socket);
154
189
devtools.store = store;
155
190
await devtools.connect ();
156
191
});
157
- test ('START response sets status to STARTED' , () {
158
- var remoteData = {
159
- 'type' : 'START' ,
160
- };
161
- expect (devtools.status, RemoteDevToolsStatus .starting);
162
- devtools.handleEventFromRemote (remoteData);
163
- expect (devtools.status, RemoteDevToolsStatus .started);
164
- });
165
192
test ('handles time travel' , () {
166
193
var remoteData = {
167
194
'type' : 'DISPATCH' ,
0 commit comments