2019-05-07 17:51:41 +02:00
|
|
|
//
|
2019-10-16 15:36:21 +02:00
|
|
|
// AccountFeedbinSyncTest.swift
|
2019-05-07 17:51:41 +02:00
|
|
|
// AccountTests
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 5/6/19.
|
|
|
|
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
@testable import Account
|
|
|
|
|
2019-10-16 15:36:21 +02:00
|
|
|
class AccountFeedbinSyncTest: XCTestCase {
|
2019-05-07 17:51:41 +02:00
|
|
|
|
|
|
|
override func setUp() {
|
|
|
|
}
|
|
|
|
|
|
|
|
override func tearDown() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func testDownloadSync() {
|
|
|
|
|
|
|
|
let testTransport = TestTransport()
|
2019-10-16 00:37:25 +02:00
|
|
|
testTransport.testFiles["tags.json"] = "tags_add.json"
|
|
|
|
testTransport.testFiles["subscriptions.json"] = "subscriptions_initial.json"
|
2019-05-07 17:51:41 +02:00
|
|
|
let account = TestAccountManager.shared.createAccount(type: .feedbin, transport: testTransport)
|
|
|
|
|
|
|
|
// Test initial folders
|
|
|
|
let initialExpection = self.expectation(description: "Initial feeds")
|
2019-10-16 15:30:37 +02:00
|
|
|
account.refreshAll() { result in
|
|
|
|
switch result {
|
|
|
|
case .success:
|
|
|
|
initialExpection.fulfill()
|
|
|
|
case .failure(let error):
|
|
|
|
XCTFail(error.localizedDescription)
|
|
|
|
}
|
2019-05-07 17:51:41 +02:00
|
|
|
}
|
|
|
|
waitForExpectations(timeout: 5, handler: nil)
|
|
|
|
|
2019-11-15 03:11:41 +01:00
|
|
|
XCTAssertEqual(224, account.flattenedWebFeeds().count)
|
2019-05-07 17:51:41 +02:00
|
|
|
|
2019-11-15 03:11:41 +01:00
|
|
|
let daringFireball = account.idToWebFeedDictionary["1296379"]
|
2019-05-07 17:51:41 +02:00
|
|
|
XCTAssertEqual("Daring Fireball", daringFireball!.name)
|
|
|
|
XCTAssertEqual("https://daringfireball.net/feeds/json", daringFireball!.url)
|
|
|
|
XCTAssertEqual("https://daringfireball.net/", daringFireball!.homePageURL)
|
|
|
|
|
|
|
|
// Test Adding a Feed
|
2019-10-16 15:30:37 +02:00
|
|
|
testTransport.testFiles["subscriptions.json"] = "subscriptions_add.json"
|
2019-05-07 17:51:41 +02:00
|
|
|
|
|
|
|
let addExpection = self.expectation(description: "Add feeds")
|
2019-10-16 15:30:37 +02:00
|
|
|
account.refreshAll() { result in
|
|
|
|
switch result {
|
|
|
|
case .success:
|
|
|
|
addExpection.fulfill()
|
|
|
|
case .failure(let error):
|
|
|
|
XCTFail(error.localizedDescription)
|
|
|
|
}
|
2019-05-07 17:51:41 +02:00
|
|
|
}
|
|
|
|
waitForExpectations(timeout: 5, handler: nil)
|
|
|
|
|
2019-11-15 03:11:41 +01:00
|
|
|
XCTAssertEqual(225, account.flattenedWebFeeds().count)
|
2019-05-07 17:51:41 +02:00
|
|
|
|
2019-11-15 03:11:41 +01:00
|
|
|
let bPixels = account.idToWebFeedDictionary["1096623"]
|
2019-10-16 00:37:25 +02:00
|
|
|
XCTAssertEqual("Beautiful Pixels", bPixels?.name)
|
|
|
|
XCTAssertEqual("https://feedpress.me/beautifulpixels", bPixels?.url)
|
|
|
|
XCTAssertEqual("https://beautifulpixels.com/", bPixels?.homePageURL)
|
2019-05-07 17:51:41 +02:00
|
|
|
|
|
|
|
TestAccountManager.shared.deleteAccount(account)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|