forked from mozilla-mobile/firefox-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestBookmarks.swift
35 lines (31 loc) · 1.52 KB
/
TestBookmarks.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import Foundation
import XCTest
import Storage
class TestBookmarks: ProfileTest {
func testBookmarks() {
withTestProfile { profile -> Void in
for i in 0...10 {
let bookmark = ShareItem(url: "http://www.example.com/\(i)", title: "Example \(i)", favicon: nil)
profile.bookmarks.shareItem(bookmark)
}
let expectation = self.expectationWithDescription("asynchronous request")
profile.bookmarks.modelForFolder(BookmarkRoots.MobileFolderGUID, success: { (model: BookmarksModel) in
// 11 bookmarks plus our two suggested sites.
XCTAssertEqual(model.current.count, 13, "We create \(model.current.count) stub bookmarks in the Mobile Bookmarks folder.")
let bookmark = model.current[0]
XCTAssertTrue(bookmark is BookmarkItem)
XCTAssertEqual((bookmark as! BookmarkItem).url, "http://www.example.com/0", "Example URL found.")
expectation.fulfill()
}, failure: { (Any) -> () in
XCTFail("Should not have failed to get mock bookmarks.")
expectation.fulfill()
})
self.waitForExpectationsWithTimeout(10.0, handler:nil)
// This'll do.
try! profile.files.remove("mock.db")
}
}
}