Skip to content

Instantly share code, notes, and snippets.

@sleroux
Created May 27, 2015 18:33
Show Gist options
  • Save sleroux/e71a26dc122ce0c994b1 to your computer and use it in GitHub Desktop.
Save sleroux/e71a26dc122ce0c994b1 to your computer and use it in GitHub Desktop.
favicon test
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