Created
May 27, 2015 18:33
-
-
Save sleroux/e71a26dc122ce0c994b1 to your computer and use it in GitHub Desktop.
favicon test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func testFaviconTable() { | |
let files = MockFiles() | |
let db = BrowserDB(files: files) | |
let history = SQLiteHistory(db: db) | |
let bookmarks = SQLiteBookmarks(db: db, favicons: history) | |
let expectation = self.expectationWithDescription("First.") | |
func done() -> Success { | |
expectation.fulfill() | |
return succeed() | |
} | |
let e1 = self.expectationWithDescription("Waiting for bookmark favicon update.") | |
func updateFavicon() -> Success { | |
func checkFaviconIdWasSetForBookmark(faviconId: Int) -> Success { | |
bookmarks.modelForRoot({ model in | |
// I'd like to do something like this | |
// let bookmark = filter(model.current) { $0.url == "http://bookmarkedurl/" } | |
if let actualFaviconId = bookmark?.favicon?.id { | |
XCTAssertEqual(faviconId, actualFaviconId) | |
e1.fulfill() | |
} | |
}, | |
failure: { _ in } | |
) | |
return succeed() | |
} | |
var fav = Favicon(url: "http://url2/", date: NSDate(), type: .Icon) | |
fav.id = 1 | |
let site = Site(url: "http://bookmarkedurl/", title: "My Bookmark") | |
return history.addFavicon(fav, forSite: site) >>== checkFaviconIdWasSetForBookmark | |
} | |
history.clearFavicons() | |
>>> { bookmarks.addToMobileBookmarks("http://bookmarkedurl/".asURL!, title: "Title", favicon: nil) } | |
>>> updateFavicon | |
>>> done | |
waitForExpectationsWithTimeout(10.0) { error in | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment