2019-05-08 00:41:32 +02:00
|
|
|
//
|
2019-10-16 15:36:21 +02:00
|
|
|
// AccountFeedbinFolderContentsSyncTest.swift
|
2019-05-08 00:41:32 +02:00
|
|
|
// AccountTests
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 5/7/19.
|
|
|
|
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
@testable import Account
|
|
|
|
|
2019-10-16 15:36:21 +02:00
|
|
|
class AccountFeedbinFolderContentsSyncTest: XCTestCase {
|
2019-05-08 00:41:32 +02:00
|
|
|
|
|
|
|
override func setUp() {
|
|
|
|
}
|
|
|
|
|
|
|
|
override func tearDown() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func testDownloadSync() {
|
|
|
|
|
|
|
|
let testTransport = TestTransport()
|
2020-08-04 19:43:29 +02:00
|
|
|
testTransport.testFiles["https://api.feedbin.com/v2/tags.json"] = "JSON/tags_add.json"
|
|
|
|
testTransport.testFiles["https://api.feedbin.com/v2/subscriptions.json"] = "JSON/subscriptions_initial.json"
|
|
|
|
testTransport.testFiles["https://api.feedbin.com/v2/taggings.json"] = "JSON/taggings_initial.json"
|
2019-05-08 00:41:32 +02:00
|
|
|
let account = TestAccountManager.shared.createAccount(type: .feedbin, transport: testTransport)
|
|
|
|
|
|
|
|
// Test initial folders
|
|
|
|
let initialExpection = self.expectation(description: "Initial contents")
|
2019-09-30 01:45:13 +02:00
|
|
|
account.refreshAll() { _ in
|
2019-05-08 00:41:32 +02:00
|
|
|
initialExpection.fulfill()
|
|
|
|
}
|
|
|
|
waitForExpectations(timeout: 5, handler: nil)
|
|
|
|
|
|
|
|
let folder = account.folders?.filter { $0.name == "Developers" } .first!
|
2019-11-15 03:11:41 +01:00
|
|
|
XCTAssertEqual(156, folder?.topLevelWebFeeds.count ?? 0)
|
|
|
|
XCTAssertEqual(2, account.topLevelWebFeeds.count)
|
2019-05-08 00:41:32 +02:00
|
|
|
|
|
|
|
// Test Adding a Feed to the folder
|
2020-08-04 19:43:29 +02:00
|
|
|
testTransport.testFiles["https://api.feedbin.com/v2/taggings.json"] = "JSON/taggings_add.json"
|
2019-05-08 00:41:32 +02:00
|
|
|
|
|
|
|
let addExpection = self.expectation(description: "Add contents")
|
2019-09-30 01:45:13 +02:00
|
|
|
account.refreshAll() { _ in
|
2019-05-08 00:41:32 +02:00
|
|
|
addExpection.fulfill()
|
|
|
|
}
|
|
|
|
waitForExpectations(timeout: 5, handler: nil)
|
|
|
|
|
2019-11-15 03:11:41 +01:00
|
|
|
XCTAssertEqual(157, folder?.topLevelWebFeeds.count ?? 0)
|
|
|
|
XCTAssertEqual(1, account.topLevelWebFeeds.count)
|
2019-05-08 00:41:32 +02:00
|
|
|
|
|
|
|
// Test Deleting some Feeds from the folder
|
2020-08-04 19:43:29 +02:00
|
|
|
testTransport.testFiles["https://api.feedbin.com/v2/taggings.json"] = "JSON/taggings_delete.json"
|
2019-05-08 00:41:32 +02:00
|
|
|
|
|
|
|
let deleteExpection = self.expectation(description: "Delete contents")
|
2019-09-30 01:45:13 +02:00
|
|
|
account.refreshAll() { _ in
|
2019-05-08 00:41:32 +02:00
|
|
|
deleteExpection.fulfill()
|
|
|
|
}
|
|
|
|
waitForExpectations(timeout: 5, handler: nil)
|
|
|
|
|
2019-11-15 03:11:41 +01:00
|
|
|
XCTAssertEqual(153, folder?.topLevelWebFeeds.count ?? 0)
|
|
|
|
XCTAssertEqual(5, account.topLevelWebFeeds.count)
|
2019-05-08 00:41:32 +02:00
|
|
|
|
|
|
|
TestAccountManager.shared.deleteAccount(account)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|