-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTestAccountViewModel.swift
57 lines (41 loc) · 1.49 KB
/
TestAccountViewModel.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
@package Twilio Message
@author Ryan Powell
@license MIT
*/
import XCTest
import RxSwift
@testable import Twilio_Message
class TestAccountViewModel: XCTestCase {
let disposeBag = DisposeBag()
func testItems() {
let expectation = XCTestExpectation(description: "\(#function)")
let accSID = Bundle.testBundle.accountSID
let authToken = Bundle.testBundle.authToken
let account = AccountViewModel(applicationSID: accSID, authToken: authToken)
account.items
.asObservable()
.skip(1) /* ignore 1st value as this is a BehaviourSubject */
.subscribe(onNext: { (items) in
XCTAssert(items.count > 0)
expectation.fulfill()
})
.disposed(by: disposeBag)
account.refresh()
self.wait(for: [expectation], timeout: 20)
}
func testError() {
let expectation = XCTestExpectation(description: "\(#function)")
let accSID = UUID().uuidString
let authToken = UUID().uuidString
let account = AccountViewModel(applicationSID: accSID, authToken: authToken)
account.listError
.subscribe(onNext: { (errorMessage) in
XCTAssert(errorMessage.count > 0)
expectation.fulfill()
})
.disposed(by: disposeBag)
account.refresh()
self.wait(for: [expectation], timeout: 20)
}
}