Skip to content

Commit

Permalink
Swiftlint autocorrect on test directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianoPAlmeida committed May 1, 2019
1 parent 96ac908 commit b71fc40
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 222 deletions.
228 changes: 114 additions & 114 deletions Tests/ActionTests/ActionTests.swift

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Tests/InputSubjectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class InputSubjectTests: QuickSpec {

XCTAssertEqual(observer.events, [
Recorded.next(10, 1),
Recorded.next(20, 2),
Recorded.next(20, 2)
])
}
}
Expand Down
12 changes: 6 additions & 6 deletions Tests/iOS-Tests/AlertActionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,27 @@ class AlertActionTests: QuickSpec {

expect(subject.isEnabled) == false
}

it("disposes of old action subscriptions when re-set") {
var subject = UIAlertAction.Action("Hi", style: .default)

var disposed = false
autoreleasepool {
let disposeBag = DisposeBag()

let action = emptyAction()
subject.rx.action = action

action
.elements
.subscribe(onNext: nil, onError: nil, onCompleted: nil, onDisposed: {
disposed = true
})
.disposed(by: disposeBag)
}

subject.rx.action = nil

expect(disposed) == true
}
}
Expand Down
50 changes: 25 additions & 25 deletions Tests/iOS-Tests/BarButtonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,68 @@ import Action

class BarButtonTests: QuickSpec {
override func spec() {

it("is nil by default") {
let subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil)
expect(subject.rx.action).to( beNil() )
}

it("respects setter") {
var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil)

let action = emptyAction()

subject.rx.action = action

expect(subject.rx.action) === action
}

it("disables the button while executing") {
var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil)

var observer: AnyObserver<Void>!
let action = CocoaAction(workFactory: { _ in
return Observable.create { (obsv) -> Disposable in
observer = obsv
return Disposables.create()
}
})

subject.rx.action = action

action.execute()
expect(subject.isEnabled).toEventually( beFalse() )

observer.onCompleted()
expect(subject.isEnabled).toEventually( beTrue() )
}

it("disables the button if the Action is disabled") {
var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil)

subject.rx.action = emptyAction(.just(false))
expect(subject.target).toEventuallyNot( beNil() )

expect(subject.isEnabled) == false
}

it("doesn't execute a disabled action when tapped") {
var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil)

var executed = false
subject.rx.action = CocoaAction(enabledIf: .just(false), workFactory: { _ in
executed = true
return .empty()
})

_ = subject.target?.perform(subject.action, with: subject)

expect(executed) == false
}

it("executes the action when tapped") {
var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil)

var executed = false
let action = CocoaAction(workFactory: { _ in
executed = true
Expand All @@ -78,30 +78,30 @@ class BarButtonTests: QuickSpec {
expect(subject.target).toEventuallyNot( beNil() )

_ = subject.target?.perform(subject.action, with: subject)

expect(executed) == true
}

it("disposes of old action subscriptions when re-set") {
var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil)

var disposed = false
autoreleasepool {
let disposeBag = DisposeBag()

let action = emptyAction()
subject.rx.action = action

action
.elements
.subscribe(onNext: nil, onError: nil, onCompleted: nil, onDisposed: {
disposed = true
})
.disposed(by: disposeBag)
}

subject.rx.action = nil

expect(disposed) == true
}
}
Expand Down
39 changes: 19 additions & 20 deletions Tests/iOS-Tests/BindToTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ class BindToTests: QuickSpec {
button.rx.bind(to: action, input: "Hi there!")
// Setting the action has an asynchronous effect of adding a target.
expect(button.allTargets.count) == 1

button.test_executeTap()

expect(called).toEventually( beTrue() )
}

it("activates a generic control event") {
var called = false
let button = UIButton()
Expand All @@ -56,12 +56,12 @@ class BindToTests: QuickSpec {
button.rx.bind(to: action, controlEvent: button.rx.tap, inputTransform: { input in "\(input)" })
// Setting the action has an asynchronous effect of adding a target.
expect(button.allTargets.count) == 1

button.test_executeTap()

expect(called).toEventually( beTrue() )
}

it("actives a UIBarButtonItem") {
var called = false
let item = UIBarButtonItem()
Expand All @@ -70,9 +70,9 @@ class BindToTests: QuickSpec {
return .empty()
})
item.rx.bind(to: action, input: "Hi there!")

_ = item.target!.perform(item.action!, with: item)

expect(called).toEventually( beTrue() )
}
it("actives a UIRefreshControl") {
Expand All @@ -83,12 +83,12 @@ class BindToTests: QuickSpec {
return .empty()
})
item.rx.bind(to: action, input: "Hi there!")

item.test_executeRefresh()

expect(called).toEventually( beTrue() )
}

describe("unbinding") {
it("unbinds actions for UIButton") {
let button = UIButton()
Expand All @@ -99,13 +99,13 @@ class BindToTests: QuickSpec {
button.rx.bind(to: action, input: "Hi there!")
// Setting the action has an asynchronous effect of adding a target.
expect(button.allTargets.count) == 1

button.rx.unbindAction()
button.test_executeTap()

expect(button.allTargets.count) == 0
}

it("unbinds actions for UIRefreshControl") {
let refreshControl = UIRefreshControl()
let action = Action<String, String>(workFactory: { _ in
Expand All @@ -115,13 +115,13 @@ class BindToTests: QuickSpec {
refreshControl.rx.bind(to: action, input: "Hi there!")
// Setting the action has an asynchronous effect of adding a target.
expect(refreshControl.allTargets.count) == 1

refreshControl.rx.unbindAction()
refreshControl.test_executeRefresh()

expect(refreshControl.allTargets.count) == 0
}

it("unbinds actions for UIBarButtonItem") {
var called = false
let item = UIBarButtonItem()
Expand All @@ -130,13 +130,12 @@ class BindToTests: QuickSpec {
return .empty()
})
item.rx.bind(to: action, input: "Hi there!")

item.rx.unbindAction()
_ = item.target?.perform(item.action!, with: item)

expect(called).to( beFalse() )
}
}
}
}

6 changes: 3 additions & 3 deletions Tests/iOS-Tests/ButtonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ class ButtonTests: QuickSpec {

expect(disposed) == true
}

it("cancels the observable if the button is deallocated") {

var disposed = false

waitUntil { done in
Expand All @@ -125,7 +125,7 @@ class ButtonTests: QuickSpec {
subject.rx.action?.execute()
}
}

expect(disposed) == true
}
}
Expand Down
19 changes: 9 additions & 10 deletions Tests/iOS-Tests/RefreshControlTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RefreshControlTests: QuickSpec {

subject.rx.action = emptyAction(.just(false))
expect(subject.allTargets.count) == 1

expect(subject.isEnabled) == false
}

Expand Down Expand Up @@ -77,9 +77,9 @@ class RefreshControlTests: QuickSpec {

// Setting the action has an asynchronous effect of adding a target.
expect(subject.allTargets.count) == 1

subject.test_executeRefresh()

expect(executed).toEventually( beTrue() )
}

Expand All @@ -105,29 +105,28 @@ class RefreshControlTests: QuickSpec {

expect(disposed) == true
}

it("disposes of old action subscriptions when re-set") {
var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil)

var disposed = false
autoreleasepool {
let disposeBag = DisposeBag()

let action = emptyAction()
subject.rx.action = action

action
.elements
.subscribe(onNext: nil, onError: nil, onCompleted: nil, onDisposed: {
disposed = true
})
.disposed(by: disposeBag)
}

subject.rx.action = nil

expect(disposed) == true
}
}
}

Loading

0 comments on commit b71fc40

Please sign in to comment.