import export working
This commit is contained in:
+102
-67
@@ -1,3 +1,5 @@
|
||||
// ignore_for_file: avoid_redundant_argument_values
|
||||
|
||||
/*
|
||||
* Copyright (c) 2024-2025 Fabian Freund.
|
||||
*
|
||||
@@ -41,16 +43,19 @@ void main() {
|
||||
group('BookmarkHTMLUtils - Import', () {
|
||||
test('should handle corrupt HTML file with malformed URIs', () async {
|
||||
// Load the corrupt fixture
|
||||
final fixtureFile =
|
||||
File('test/utils/bookmarks/fixtures/bookmarks.corrupt.html');
|
||||
final fixtureFile = File(
|
||||
'test/utils/bookmarks/fixtures/bookmarks.corrupt.html',
|
||||
);
|
||||
final htmlString = await fixtureFile.readAsString();
|
||||
|
||||
// Mock the service calls
|
||||
when(mockService.eraseEverything(any)).thenAnswer((_) async {});
|
||||
when(mockService.addFolder(any, any, any))
|
||||
.thenAnswer((_) async => 'generated_guid');
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'generated_guid');
|
||||
when(
|
||||
mockService.addFolder(any, any, any),
|
||||
).thenAnswer((_) async => 'generated_guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'generated_guid');
|
||||
|
||||
final count = await utils.importFromHTML(htmlString, replace: true);
|
||||
|
||||
@@ -60,15 +65,18 @@ void main() {
|
||||
});
|
||||
|
||||
test('should import from valid HTML file', () async {
|
||||
final fixtureFile =
|
||||
File('test/utils/bookmarks/fixtures/bookmarks.preplaces.html');
|
||||
final fixtureFile = File(
|
||||
'test/utils/bookmarks/fixtures/bookmarks.preplaces.html',
|
||||
);
|
||||
final htmlString = await fixtureFile.readAsString();
|
||||
|
||||
when(mockService.eraseEverything(any)).thenAnswer((_) async {});
|
||||
when(mockService.addFolder(any, any, any))
|
||||
.thenAnswer((_) async => 'folder_guid');
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'bookmark_guid');
|
||||
when(
|
||||
mockService.addFolder(any, any, any),
|
||||
).thenAnswer((_) async => 'folder_guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'bookmark_guid');
|
||||
|
||||
final count = await utils.importFromHTML(htmlString, replace: true);
|
||||
|
||||
@@ -105,8 +113,9 @@ void main() {
|
||||
</DL>
|
||||
''';
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'guid');
|
||||
|
||||
await utils.importFromHTML(simpleHtml);
|
||||
|
||||
@@ -123,8 +132,9 @@ void main() {
|
||||
</DL>
|
||||
''';
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'guid');
|
||||
|
||||
final count = await utils.importFromHTML(htmlWithSpecialChars);
|
||||
|
||||
@@ -146,8 +156,9 @@ void main() {
|
||||
</DL>
|
||||
''';
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'guid');
|
||||
|
||||
final count = await utils.importFromHTML(htmlWithDates);
|
||||
|
||||
@@ -171,10 +182,12 @@ void main() {
|
||||
</DL>
|
||||
''';
|
||||
|
||||
when(mockService.addFolder(any, any, any))
|
||||
.thenAnswer((_) async => 'folder_guid');
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'bookmark_guid');
|
||||
when(
|
||||
mockService.addFolder(any, any, any),
|
||||
).thenAnswer((_) async => 'folder_guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'bookmark_guid');
|
||||
|
||||
final count = await utils.importFromHTML(htmlWithFolders);
|
||||
|
||||
@@ -196,8 +209,9 @@ void main() {
|
||||
''';
|
||||
|
||||
when(mockService.eraseEverything(any)).thenAnswer((_) async {});
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'guid');
|
||||
|
||||
await utils.importFromHTML(htmlWithToolbar, replace: true);
|
||||
|
||||
@@ -222,8 +236,9 @@ void main() {
|
||||
''';
|
||||
|
||||
when(mockService.eraseEverything(any)).thenAnswer((_) async {});
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'guid');
|
||||
|
||||
await utils.importFromHTML(htmlWithUnfiled, replace: true);
|
||||
|
||||
@@ -245,8 +260,9 @@ void main() {
|
||||
</DL>
|
||||
''';
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'guid');
|
||||
|
||||
final count = await utils.importFromHTML(htmlWithSeparator);
|
||||
|
||||
@@ -265,8 +281,9 @@ void main() {
|
||||
</DL>
|
||||
''';
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'guid');
|
||||
|
||||
final count = await utils.importFromHTML(htmlWithoutUrl);
|
||||
|
||||
@@ -284,8 +301,9 @@ void main() {
|
||||
</DL>
|
||||
''';
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'guid');
|
||||
|
||||
final count = await utils.importFromHTML(htmlWithInvalidUrl);
|
||||
|
||||
@@ -293,14 +311,17 @@ void main() {
|
||||
});
|
||||
|
||||
test('should handle single frame HTML', () async {
|
||||
final fixtureFile =
|
||||
File('test/utils/bookmarks/fixtures/bookmarks_html_singleframe.html');
|
||||
final fixtureFile = File(
|
||||
'test/utils/bookmarks/fixtures/bookmarks_html_singleframe.html',
|
||||
);
|
||||
final htmlString = await fixtureFile.readAsString();
|
||||
|
||||
when(mockService.addFolder(any, any, any))
|
||||
.thenAnswer((_) async => 'folder_guid');
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'bookmark_guid');
|
||||
when(
|
||||
mockService.addFolder(any, any, any),
|
||||
).thenAnswer((_) async => 'folder_guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'bookmark_guid');
|
||||
|
||||
final count = await utils.importFromHTML(htmlString);
|
||||
|
||||
@@ -333,8 +354,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final html = await utils.exportToHTML(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -368,8 +390,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final html = await utils.exportToHTML(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -402,8 +425,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final html = await utils.exportToHTML(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -424,8 +448,9 @@ void main() {
|
||||
children: [],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final html = await utils.exportToHTML(root: BookmarkRoot.toolbar);
|
||||
|
||||
@@ -447,8 +472,9 @@ void main() {
|
||||
children: [],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final html = await utils.exportToHTML(root: BookmarkRoot.unfiled);
|
||||
|
||||
@@ -501,8 +527,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final html = await utils.exportToHTML(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -543,8 +570,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final html = await utils.exportToHTML(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -590,8 +618,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final html = await utils.exportToHTML(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -601,9 +630,10 @@ void main() {
|
||||
expect(html, contains('</H3>'));
|
||||
});
|
||||
|
||||
test('should throw when tree cannot be fetched', () async {
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => null);
|
||||
test('should throw when tree cannot be fetched', () {
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => null);
|
||||
|
||||
expect(
|
||||
() => utils.exportToHTML(root: BookmarkRoot.menu),
|
||||
@@ -624,8 +654,9 @@ void main() {
|
||||
children: [],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final html = await utils.exportToHTML(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -659,8 +690,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final html = await utils.exportToHTML(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -708,8 +740,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
// Export
|
||||
final html = await utils.exportToHTML(root: BookmarkRoot.menu);
|
||||
@@ -717,10 +750,12 @@ void main() {
|
||||
|
||||
// Re-import
|
||||
when(mockService.eraseEverything(any)).thenAnswer((_) async {});
|
||||
when(mockService.addFolder(any, any, any))
|
||||
.thenAnswer((_) async => 'folder1_____');
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'bookmark1___');
|
||||
when(
|
||||
mockService.addFolder(any, any, any),
|
||||
).thenAnswer((_) async => 'folder1_____');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'bookmark1___');
|
||||
|
||||
final count = await utils.importFromHTML(html, replace: true);
|
||||
|
||||
|
||||
+74
-54
@@ -1,3 +1,5 @@
|
||||
// ignore_for_file: avoid_redundant_argument_values, avoid_dynamic_calls
|
||||
|
||||
/*
|
||||
* Copyright (c) 2024-2025 Fabian Freund.
|
||||
*
|
||||
@@ -108,10 +110,7 @@ void main() {
|
||||
|
||||
when(mockService.eraseEverything(any)).thenAnswer((_) async {});
|
||||
|
||||
await utils.importFromJSON(
|
||||
jsonEncode(jsonData),
|
||||
replace: true,
|
||||
);
|
||||
await utils.importFromJSON(jsonEncode(jsonData), replace: true);
|
||||
|
||||
verify(mockService.eraseEverything(BookmarkRoot.root)).called(1);
|
||||
});
|
||||
@@ -150,8 +149,9 @@ void main() {
|
||||
],
|
||||
};
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'bookmark1___');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'bookmark1___');
|
||||
|
||||
final count = await utils.importFromJSON(jsonEncode(jsonData));
|
||||
|
||||
@@ -184,8 +184,9 @@ void main() {
|
||||
],
|
||||
};
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'bookmark1___');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'bookmark1___');
|
||||
|
||||
final count = await utils.importFromJSON(jsonEncode(jsonData));
|
||||
|
||||
@@ -224,8 +225,9 @@ void main() {
|
||||
],
|
||||
};
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'valid1______');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'valid1______');
|
||||
|
||||
final count = await utils.importFromJSON(jsonEncode(jsonData));
|
||||
|
||||
@@ -267,10 +269,12 @@ void main() {
|
||||
],
|
||||
};
|
||||
|
||||
when(mockService.addFolder(any, any, any))
|
||||
.thenAnswer((_) async => 'folder1_____');
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'bookmark1___');
|
||||
when(
|
||||
mockService.addFolder(any, any, any),
|
||||
).thenAnswer((_) async => 'folder1_____');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'bookmark1___');
|
||||
|
||||
final count = await utils.importFromJSON(jsonEncode(jsonData));
|
||||
|
||||
@@ -299,10 +303,7 @@ void main() {
|
||||
'type': 'text/x-moz-place',
|
||||
'uri': 'https://example.com/1',
|
||||
},
|
||||
{
|
||||
'guid': 'separator___',
|
||||
'type': 'text/x-moz-place-separator',
|
||||
},
|
||||
{'guid': 'separator___', 'type': 'text/x-moz-place-separator'},
|
||||
{
|
||||
'guid': 'bookmark2___',
|
||||
'title': 'Second Bookmark',
|
||||
@@ -314,8 +315,9 @@ void main() {
|
||||
],
|
||||
};
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((invocation) async => 'generated_guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((invocation) async => 'generated_guid');
|
||||
|
||||
final count = await utils.importFromJSON(jsonEncode(jsonData));
|
||||
|
||||
@@ -350,10 +352,12 @@ void main() {
|
||||
],
|
||||
};
|
||||
|
||||
when(mockService.addFolder(any, any, any))
|
||||
.thenAnswer((_) async => 'folder1_____');
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'shortcut1___');
|
||||
when(
|
||||
mockService.addFolder(any, any, any),
|
||||
).thenAnswer((_) async => 'folder1_____');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'shortcut1___');
|
||||
|
||||
await utils.importFromJSON(jsonEncode(jsonData));
|
||||
|
||||
@@ -384,8 +388,9 @@ void main() {
|
||||
],
|
||||
};
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'shortcut1___');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'shortcut1___');
|
||||
|
||||
await utils.importFromJSON(jsonEncode(jsonData));
|
||||
|
||||
@@ -410,10 +415,12 @@ void main() {
|
||||
|
||||
// Mock the service calls
|
||||
when(mockService.eraseEverything(any)).thenAnswer((_) async {});
|
||||
when(mockService.addFolder(any, any, any))
|
||||
.thenAnswer((invocation) async => 'generated_guid');
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((invocation) async => 'generated_guid');
|
||||
when(
|
||||
mockService.addFolder(any, any, any),
|
||||
).thenAnswer((invocation) async => 'generated_guid');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((invocation) async => 'generated_guid');
|
||||
|
||||
final count = await utils.importFromJSON(jsonString, replace: true);
|
||||
|
||||
@@ -440,8 +447,9 @@ void main() {
|
||||
],
|
||||
};
|
||||
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenThrow(Exception('Database error'));
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenThrow(Exception('Database error'));
|
||||
|
||||
// Should not throw, but should log and continue
|
||||
final count = await utils.importFromJSON(jsonEncode(jsonData));
|
||||
@@ -475,8 +483,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final result = await utils.exportToJson(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -529,8 +538,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final result = await utils.exportToJson(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -565,8 +575,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final result = await utils.exportToJson(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -600,8 +611,9 @@ void main() {
|
||||
children: [],
|
||||
);
|
||||
|
||||
when(mockService.getTree(testCase.$1.id, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(testCase.$1.id, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final result = await utils.exportToJson(root: testCase.$1);
|
||||
|
||||
@@ -654,8 +666,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final result = await utils.exportToJson(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -667,9 +680,10 @@ void main() {
|
||||
expect(children[2]['index'], equals(2));
|
||||
});
|
||||
|
||||
test('should throw when tree cannot be fetched', () async {
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => null);
|
||||
test('should throw when tree cannot be fetched', () {
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => null);
|
||||
|
||||
expect(
|
||||
() => utils.exportToJson(root: BookmarkRoot.menu),
|
||||
@@ -701,8 +715,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
final result = await utils.exportToJson(root: BookmarkRoot.menu);
|
||||
|
||||
@@ -752,8 +767,9 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
when(mockService.getTree(any, recursive: true))
|
||||
.thenAnswer((_) async => mockNode);
|
||||
when(
|
||||
mockService.getTree(any, recursive: true),
|
||||
).thenAnswer((_) async => mockNode);
|
||||
|
||||
// Export
|
||||
final exported = await utils.exportToJson(root: BookmarkRoot.menu);
|
||||
@@ -761,12 +777,16 @@ void main() {
|
||||
|
||||
// Re-import
|
||||
when(mockService.eraseEverything(any)).thenAnswer((_) async {});
|
||||
when(mockService.addFolder(any, any, any))
|
||||
.thenAnswer((_) async => 'folder1_____');
|
||||
when(mockService.addItem(any, any, any, any))
|
||||
.thenAnswer((_) async => 'bookmark1___');
|
||||
when(
|
||||
mockService.addFolder(any, any, any),
|
||||
).thenAnswer((_) async => 'folder1_____');
|
||||
when(
|
||||
mockService.addItem(any, any, any, any),
|
||||
).thenAnswer((_) async => 'bookmark1___');
|
||||
|
||||
final jsonString = jsonEncode({'children': [exported]});
|
||||
final jsonString = jsonEncode({
|
||||
'children': [exported],
|
||||
});
|
||||
final count = await utils.importFromJSON(jsonString, replace: true);
|
||||
|
||||
expect(count, equals(1)); // One bookmark imported
|
||||
|
||||
Reference in New Issue
Block a user