Skip to content

Commit 50b14c8

Browse files
authored
Added an Action test case.
1 parent 6be0287 commit 50b14c8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Tests/ReactiveSwiftTests/ActionSpec.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,23 @@ class ActionSpec: QuickSpec {
5858
action.errors.observeValues { errors.append($0) }
5959
action.completed.observeValues { completedCount += 1 }
6060
}
61+
62+
it("should retain the state property") {
63+
var property: MutableProperty<Bool>? = MutableProperty(false)
64+
weak var weakProperty = property
65+
66+
var action: Action<(), (), NoError>? = Action(state: property!, enabledIf: { _ in true }) { _ in
67+
return .empty
68+
}
69+
70+
expect(weakProperty).toNot(beNil())
71+
72+
property = nil
73+
expect(weakProperty).toNot(beNil())
74+
75+
action = nil
76+
expect(weakProperty).to(beNil())
77+
}
6178

6279
it("should be disabled and not executing after initialization") {
6380
expect(action.isEnabled.value) == false

0 commit comments

Comments
 (0)