Skip to content

Commit 73d5d8e

Browse files
committed
tests
1 parent 6b443b5 commit 73d5d8e

File tree

1 file changed

+64
-44
lines changed

1 file changed

+64
-44
lines changed

test/storage/streams_test.dart

Lines changed: 64 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -367,61 +367,81 @@ void main() {
367367
});
368368

369369
test('executeUpdate', () async {
370-
expect(
371-
await rxStorage.getString('String'),
372-
kTestValues['String'],
373-
);
374-
await rxStorage.executeUpdate<String>(
375-
'String',
376-
(s) => s as String?, // read
377-
(s) => 'Transformed $s', // modify,
378-
(s) => s, // write
379-
);
380-
expect(
381-
await rxStorage.getString('String'),
382-
'Transformed ${kTestValues['String']}',
383-
);
384-
385-
expect(
386-
await rxStorage.readUser(),
387-
user1,
388-
);
389-
await rxStorage.executeUpdate<User>(
390-
'User',
391-
jsonStringToUser, // read
392-
(user) =>
393-
user != null ? user.withName('Transformed ${user.name}') : null,
394-
// modify
395-
userToJsonString, // write
396-
);
397-
expect(
398-
await rxStorage.readUser(),
399-
user1.withName('Transformed ${user1.name}'),
400-
);
401-
402-
// forward error.
403-
fakeStorage.throws = true;
370+
{
371+
final expected = 'Transformed ${kTestValues['String']}';
372+
expect(
373+
rxStorage.getStringStream('String'),
374+
emitsInOrder(<Object>[anything, expected]),
375+
);
376+
expect(
377+
await rxStorage.getString('String'),
378+
kTestValues['String'],
379+
);
404380

405-
expect(
406-
rxStorage.executeUpdate<String>(
381+
await rxStorage.executeUpdate<String>(
407382
'String',
408383
(s) => s as String?, // read
409384
(s) => 'Transformed $s', // modify,
410385
(s) => s, // write
411-
),
412-
throwsException,
413-
);
414-
expect(
415-
rxStorage.executeUpdate<User>(
386+
);
387+
388+
expect(
389+
await rxStorage.getString('String'),
390+
expected,
391+
);
392+
}
393+
394+
{
395+
final expected = user1.withName('Transformed ${user1.name}');
396+
expect(
397+
rxStorage.observeUser(),
398+
emitsInOrder(<Object>[anything, expected]),
399+
);
400+
expect(
401+
await rxStorage.readUser(),
402+
user1,
403+
);
404+
405+
await rxStorage.executeUpdate<User>(
416406
'User',
417407
jsonStringToUser, // read
418408
(user) =>
419409
user != null ? user.withName('Transformed ${user.name}') : null,
420410
// modify
421411
userToJsonString, // write
422-
),
423-
throwsException,
424-
);
412+
);
413+
414+
expect(
415+
await rxStorage.readUser(),
416+
expected,
417+
);
418+
}
419+
420+
{
421+
// forward error.
422+
fakeStorage.throws = true;
423+
424+
expect(
425+
rxStorage.executeUpdate<String>(
426+
'String',
427+
(s) => s as String?, // read
428+
(s) => 'Transformed $s', // modify,
429+
(s) => s, // write
430+
),
431+
throwsException,
432+
);
433+
expect(
434+
rxStorage.executeUpdate<User>(
435+
'User',
436+
jsonStringToUser, // read
437+
(user) =>
438+
user != null ? user.withName('Transformed ${user.name}') : null,
439+
// modify
440+
userToJsonString, // write
441+
),
442+
throwsException,
443+
);
444+
}
425445
});
426446
});
427447
}

0 commit comments

Comments
 (0)