Skip to content

Commit

Permalink
Update FFS favorites migration test to verify favorites array order
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Nov 23, 2023
1 parent a04c4d7 commit b390d94
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Tests/BookmarksTests/BookmarkUtilsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ final class BookmarkUtilsTests: XCTestCase {
let bookmarkTree = BookmarkTree {
Bookmark(id: "1")
Bookmark(id: "2", favoritedOn: [.unified])
Folder(id: "10") {
Bookmark(id: "12", favoritedOn: [.unified])
}
Bookmark(id: "3", favoritedOn: [.unified])
Bookmark(id: "4", favoritedOn: [.unified])
}
Expand All @@ -69,15 +72,22 @@ final class BookmarkUtilsTests: XCTestCase {
bookmarkTree.createEntities(in: context)

try! context.save()
let favoritesArray = BookmarkUtils.fetchFavoritesFolder(withUUID: FavoritesFolderID.unified.rawValue, in: context)?.favoritesArray.compactMap(\.uuid)

BookmarkUtils.migrateToFormFactorSpecificFavorites(byCopyingExistingTo: .mobile, in: context)

try! context.save()

let mobileFavoritesArray = BookmarkUtils.fetchFavoritesFolder(withUUID: FavoritesFolderID.mobile.rawValue, in: context)?.favoritesArray.compactMap(\.uuid)
XCTAssertEqual(favoritesArray, mobileFavoritesArray)

let rootFolder = BookmarkUtils.fetchRootFolder(context)!
assertEquivalent(withTimestamps: false, rootFolder, BookmarkTree {
Bookmark(id: "1")
Bookmark(id: "2", favoritedOn: [.mobile, .unified])
Folder(id: "10") {
Bookmark(id: "12", favoritedOn: [.mobile, .unified])
}
Bookmark(id: "3", favoritedOn: [.mobile, .unified])
Bookmark(id: "4", favoritedOn: [.mobile, .unified])
})
Expand Down

0 comments on commit b390d94

Please sign in to comment.