Skip to content

Commit

Permalink
[ADD] Signal.concat disposing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Shnitko committed Jan 22, 2016
1 parent d8b10ec commit 530a7df
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ReactiveCocoaTests/Swift/FlattenSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,49 @@ class FlattenSpec: QuickSpec {
}
}

describe("Signal.concat") {

var pipe: Pipe!
var disposable: Disposable?

beforeEach {
pipe = Signal.pipe()
disposable = pipe.0.flatten(.Concat).observe { _ in }
}

afterEach {
disposable?.dispose()
}

context("disposing") {
var disposed = false

beforeEach {
disposed = false
pipe.1.sendNext(SignalProducer<Int, TestError> { _, disposable in
disposable += ActionDisposable {
disposed = true
}
})
}

it("should dispose inner signals when outer signal interrupted") {
pipe.1.sendInterrupted()
expect(disposed).to(beTrue())
}

it("should dispose inner signals when outer signal failed") {
pipe.1.sendFailed(TestError.Default)
expect(disposed).to(beTrue())
}

it("should not dispose inner signals when outer signal completed") {
pipe.1.sendCompleted()
expect(disposed).to(beFalse())
}
}
}

describe("SignalProducer.switchToLatest") {
it("disposes original signal when result signal interrupted") {

Expand Down

0 comments on commit 530a7df

Please sign in to comment.