mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-13 04:56:21 +01:00
40 lines
1.4 KiB
Dart
40 lines
1.4 KiB
Dart
|
import 'package:nc_photos/use_case/compat/v32.dart';
|
||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||
|
import 'package:test/test.dart';
|
||
|
|
||
|
void main() {
|
||
|
group("CompatV32", () {
|
||
|
group("isPrefNeedMigration", () {
|
||
|
test("w/ accounts", () async {
|
||
|
SharedPreferences.setMockInitialValues({
|
||
|
"accounts": [
|
||
|
"""{"scheme":"http","address":"example.com","username":"admin","password":"123456","roots":["dir","dir2"]}""",
|
||
|
],
|
||
|
});
|
||
|
expect(await CompatV32.isPrefNeedMigration(), true);
|
||
|
});
|
||
|
|
||
|
test("w/o accounts", () async {
|
||
|
SharedPreferences.setMockInitialValues({
|
||
|
"hello": "world",
|
||
|
});
|
||
|
expect(await CompatV32.isPrefNeedMigration(), false);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
test("migratePref", () async {
|
||
|
SharedPreferences.setMockInitialValues({
|
||
|
"accounts": [
|
||
|
"""{"scheme":"http","address":"example.com","username":"admin","password":"123456","roots":["dir","dir2"]}""",
|
||
|
],
|
||
|
});
|
||
|
await CompatV32.migratePref();
|
||
|
final pref = await SharedPreferences.getInstance();
|
||
|
expect(pref.getStringList("accounts2"), [
|
||
|
"""{"account":{"scheme":"http","address":"example.com","username":"admin","password":"123456","roots":["dir","dir2"]},"settings":{"isEnableFaceRecognitionApp":true}}""",
|
||
|
]);
|
||
|
expect(pref.containsKey("accounts"), false);
|
||
|
});
|
||
|
});
|
||
|
}
|