1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-19 19:51:35 +03:00
vimr/VimR/VimRTests/RxSwiftCommonsTest.swift

39 lines
819 B
Swift
Raw Normal View History

2017-05-03 22:43:45 +03:00
/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Nimble
import RxSwift
import RxTest
2020-09-19 00:14:20 +03:00
import XCTest
2017-05-03 22:43:45 +03:00
class RxSwiftCommonsTest: XCTestCase {
func testMapOmittingNil() {
let scheduler = TestScheduler(initialClock: 0)
let xs = scheduler.createHotObservable(
[
2020-12-25 16:31:34 +03:00
Recorded.next(150, 1),
Recorded.next(210, 2),
Recorded.next(220, 3),
Recorded.next(230, 4),
Recorded.next(240, 5),
Recorded.next(260, 6),
Recorded.completed(300),
2017-05-03 22:43:45 +03:00
]
)
2019-03-09 19:58:46 +03:00
let res = scheduler.start { xs.compactMap { $0 % 2 == 0 ? $0 : nil } }
2017-05-03 22:43:45 +03:00
let correctMessages = [
2020-12-25 16:31:34 +03:00
Recorded.next(210, 2),
Recorded.next(230, 4),
Recorded.next(260, 6),
Recorded.completed(300),
2017-05-03 22:43:45 +03:00
]
2020-12-25 16:31:34 +03:00
expect(res.events).to(equal(correctMessages))
2017-05-03 22:43:45 +03:00
}
}