38 lines
1.2 KiB
Dart
38 lines
1.2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:marianum_mobile/api/cache_store.dart';
|
|
|
|
void main() {
|
|
group('CacheStore.parse', () {
|
|
test('splits the timestamp header from the payload', () {
|
|
final entry = CacheStore.parse('1700000000000\n{"a":"b\\nc"}');
|
|
expect(entry!.lastUpdate, 1700000000000);
|
|
expect(entry.json, '{"a":"b\\nc"}');
|
|
});
|
|
|
|
test('keeps newlines inside the payload', () {
|
|
expect(CacheStore.parse('1\nline1\nline2')!.json, 'line1\nline2');
|
|
});
|
|
|
|
test('rejects files without a valid header', () {
|
|
expect(CacheStore.parse('{"a":1}'), isNull);
|
|
expect(CacheStore.parse('abc\n{}'), isNull);
|
|
});
|
|
});
|
|
|
|
group('CacheStore.directoryName', () {
|
|
test('keeps the original directory for the pre-multi-account account', () {
|
|
expect(CacheStore.directoryName(''), 'request_cache');
|
|
});
|
|
|
|
test('separates accounts and the signed-out state', () {
|
|
final names = {
|
|
CacheStore.directoryName(''),
|
|
CacheStore.directoryName('a1b2'),
|
|
CacheStore.directoryName('c3d4'),
|
|
CacheStore.directoryName(null),
|
|
};
|
|
expect(names, hasLength(4));
|
|
});
|
|
});
|
|
}
|