forked from spotify/Mobius.swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventSource+ExtensionsTests.swift
More file actions
40 lines (33 loc) · 1.33 KB
/
EventSource+ExtensionsTests.swift
File metadata and controls
40 lines (33 loc) · 1.33 KB
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
// Copyright Spotify AB.
// SPDX-License-Identifier: Apache-2.0
import MobiusCore
import MobiusExtras
import Nimble
import Quick
class EventSourceExtensionsTests: QuickSpec {
// swiftlint:disable:next function_body_length
override class func spec() {
describe("EventSource") {
var subscribedIntConsumer: ((Int) -> Void)?
var intEventSource: AnyEventSource<Int>!
beforeEach {
intEventSource = AnyEventSource { (consumer: @escaping (Int) -> Void) in
subscribedIntConsumer = consumer
return EmptyDisposable()
}
}
context("when mapping the event source from one type to another") {
var stringEventSource: AnyEventSource<String>!
beforeEach {
stringEventSource = intEventSource.map { integer in "\(integer)" }
}
it("it creates a new event source, which translates and forwards events from the original one") {
var emittedStringEvents: [String] = []
_ = stringEventSource.subscribe { string in emittedStringEvents.append(string) }
subscribedIntConsumer?(12)
expect(emittedStringEvents).to(equal(["12"]))
}
}
}
}
}