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