Skip to content

Commit

Permalink
Create parse_local_storage_test.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
alann-maulana committed Nov 13, 2019
1 parent 718c7f6 commit 14cc510
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/parse_local_storage_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'package:flutter_parse/flutter_parse.dart';
import 'package:flutter_parse/src/parse_local_storage.dart';
import 'package:test/test.dart';

void main() {
group('Parse Local Storage', () {
setUpAll(() {
final ParseConfiguration _configuration = ParseConfiguration(
server: 'SERVER',
applicationId: 'APPLICATION_ID',
clientKey: 'CLIENT_KEY',
enableLogging: true,
);
Parse.initialize(_configuration);
});

const String key1 = 'default local storage must be empty';
test(key1, () async {
final localStorage = await parseLocalStorage.get(key1);

expect(localStorage.isEmpty, isTrue);
});

const String key2 = 'adding local storage with an item must not be empty';
test(key2, () async {
final localStorage = await parseLocalStorage.get(key2);
await localStorage.setItem('first', 1);

expect(localStorage.isEmpty, isFalse);
expect(localStorage.getItem('first'), 1);
});

const String key3 =
'remove after adding local storage with an item must be empty';
test(key3, () async {
final localStorage = await parseLocalStorage.get(key3);
await localStorage.setItem('second', 2);

expect(localStorage.isEmpty, isFalse);
expect(localStorage.getItem('second'), 2);

await localStorage.delete();
expect(localStorage.isEmpty, isTrue);
});
});
}

0 comments on commit 14cc510

Please sign in to comment.