This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip test updates for last bit of cov
- Loading branch information
1 parent
532afcc
commit da39508
Showing
8 changed files
with
274 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:fluttercon_cache/fluttercon_cache.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('speakerCacheKey', () { | ||
test('returns the correct cache key', () { | ||
expect(speakerCacheKey('123'), equals('speaker_123')); | ||
}); | ||
}); | ||
|
||
group('speakerTalksCacheKey', () { | ||
test('returns the correct cache key', () { | ||
expect(speakerTalksCacheKey('1,2,3'), equals('speaker_talks_1,2,3')); | ||
}); | ||
}); | ||
|
||
group('favoritesCacheKey', () { | ||
test('returns the correct cache key', () { | ||
expect(favoritesCacheKey('123'), equals('favorites_123')); | ||
}); | ||
}); | ||
|
||
group('talkCacheKey', () { | ||
test('returns the correct cache key', () { | ||
expect(talkCacheKey('123'), equals('talk_123')); | ||
}); | ||
}); | ||
} |
29 changes: 29 additions & 0 deletions
29
api/packages/fluttercon_cache/test/src/utils/try_get_from_cache_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:fluttercon_cache/fluttercon_cache.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('tryGetFromCache', () { | ||
const cacheData = {'data': 'value'}; | ||
const orElseData = {'data': 'orElse value'}; | ||
test('returns from cache if found', () async { | ||
final result = await tryGetFromCache( | ||
getFromCache: () async => jsonEncode(cacheData), | ||
fromJson: (json) => json, | ||
orElse: () async => orElseData, | ||
); | ||
|
||
expect(result, equals(cacheData)); | ||
}); | ||
|
||
test('calls orElse if cache returns null', () async { | ||
final result = await tryGetFromCache( | ||
getFromCache: () async => null, | ||
fromJson: (json) => json, | ||
orElse: () async => orElseData, | ||
); | ||
expect(result, equals(orElseData)); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.