Skip to content

Commit

Permalink
feat: add test for anonymous function
Browse files Browse the repository at this point in the history
  • Loading branch information
ashrafkamarudin committed May 22, 2020
1 parent 97bc7a3 commit 5d15512
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/flutter_cache_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,41 @@ void main() {

test('It can use anonymous function', () async {

await Cache.remember('key', () {
return 'old';
}, 5);

expect(await Cache.remember('key', () {
return 'new';
}), 'old');

await Future.delayed(const Duration(seconds: 6), (){});

expect(await Cache.remember('key', () {
return 'new';
}), 'new');

expect(await Cache.remember('string', () {
return 'test';
}), 'test');

expect(await Cache.remember('string', () => 'test'), 'test');
});

test('It will load first then fetch', () async {

await Cache.remember('key', () {
return 'old';
}, 5);

expect(await Cache.remember('key', () {
return 'new';
}), 'old');

await Future.delayed(const Duration(seconds: 6), (){});

expect(await Cache.remember('key', () {
return 'new';
}), 'new');
});
}

0 comments on commit 5d15512

Please sign in to comment.