@@ -23,6 +23,10 @@ Stream<DataState<T>> _streamFor<T>(DataStateNotifier<T> notifier) {
2323 return controller.stream.asBroadcastStream ();
2424}
2525
26+ // can use (stream, emitsInOrder) or (stream.first, completion)
27+ // await expectLater(stream.first,
28+ // completion(DataState<List<Familia>>([], isLoading: true)));
29+
2630void main () async {
2731 setUp (setUpFn);
2832 tearDown (tearDownFn);
@@ -69,14 +73,6 @@ void main() async {
6973 final notifier = container.familia.watchAllNotifier (remote: true );
7074 final stream = _streamFor (notifier);
7175
72- // await expectLater(stream.first,
73- // completion(DataState<List<Familia>>([], isLoading: true)));
74- // await expectLater(
75- // stream.first,
76- // completion(isA<DataState>()
77- // .having((s) => s.isLoading, 'isLoading', isFalse)
78- // .having((s) => s.exception, 'exception', isA<Exception>())));
79-
8076 await expectLater (
8177 stream,
8278 emitsInOrder ([
@@ -86,7 +82,6 @@ void main() async {
8682 .having ((s) => s.exception, 'exception' , isA <Exception >())
8783 ]),
8884 );
89- print ('1st ok' );
9085
9186 // now server will successfully respond with two familia
9287 container.read (responseProvider.notifier).state = TestResponse .json ('''
@@ -95,66 +90,16 @@ void main() async {
9590
9691 // reload
9792 await notifier.reload ();
98- print ('after reload' );
99-
100- // TODO fix this
101- // not working here as saveMany/save are not emitting
102- // this was there before:
103- // core._notify([op.edge.from, op.edge.to],
104- // metadata: op.edge.name, type: type);
105- // (now should listen to stream from database and emit, cause isolates)
10693
10794 final familia = Familia (id: '1' , surname: 'Corleone' );
10895 final familia2 = Familia (id: '2' , surname: 'Soprano' );
10996
11097 await expectLater (
111- stream.first ,
112- completion (
113- DataState <List <Familia >>([], isLoading: false ),
114- ),
98+ stream,
99+ emitsInOrder ([
100+ DataState <List <Familia >>([familia, familia2 ], isLoading: false ),
101+ ] ),
115102 );
116- print ('2nd ok' );
117-
118- // final listener = Listener<DataState<List<Familia>>?>();
119-
120- // container.read(responseProvider.notifier).state =
121- // TestResponse((_) => throw Exception('unreachable'));
122- // final notifier = container.familia.watchAllNotifier();
123-
124- // dispose = notifier.addListener(listener);
125-
126- // verify(listener(DataState([], isLoading: true))).called(1);
127- // await oneMs();
128-
129- // // finished loading but found the network unreachable
130- // verify(listener(argThat())
131- // .called(1);
132- // verifyNoMoreInteractions(listener);
133-
134- // // now server will successfully respond with two familia
135- // container.read(responseProvider.notifier).state = TestResponse.json('''
136- // [{ "id": "1", "surname": "Corleone" }, { "id": "2", "surname": "Soprano" }]
137- // ''');
138-
139- // // reload
140- // await notifier.reload();
141-
142- // final familia = Familia(id: '1', surname: 'Corleone');
143- // final familia2 = Familia(id: '2', surname: 'Soprano');
144-
145- // // loads again, for now exception remains
146- // verify(listener(argThat(isA<DataState>()
147- // .having((s) => s.isLoading, 'isLoading', isTrue)
148- // .having((s) => s.exception, 'exception', isA<Exception>()))))
149- // .called(1);
150-
151- // await oneMs();
152-
153- // // now responds with models, loading done, and no exception
154- // verify(listener(argThat(isA<DataState>().having(
155- // (s) => s.model, 'model', unorderedEquals([familia, familia2])))))
156- // .called(1);
157- // verifyNoMoreInteractions(listener);
158103 });
159104
160105 test ('watchOne with remote=true' , () async {
0 commit comments