Skip to content

Commit 35aa8e4

Browse files
author
Aleksei Minaev
committed
Add test for ReplaySubject that returns correct values while subscription is made in another subscription
1 parent 74ab5ba commit 35aa8e4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ReactiveObjCTests/RACSubjectSpec.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ - (void)didSubscribeWithDisposable:(RACCompoundDisposable *)disposable {
9696
qck_beforeEach(^{
9797
subject = [RACReplaySubject replaySubjectWithCapacity:1];
9898
});
99+
100+
qck_it(@"should send same latest value to multiple subscribers in another subscription", ^{
101+
__block NSMutableArray *values = [NSMutableArray array];
102+
103+
[subject subscribeNext:^(id _Nullable item1) {
104+
[values addObject:item1];
105+
[[subject take:1] subscribeNext:^(id _Nullable item2) {
106+
[values addObject:item2];
107+
}];
108+
}];
109+
[subject sendNext:@1];
110+
[subject sendNext:@2];
111+
112+
expect(values).to(equal(@[@1, @1, @2, @2]));
113+
});
99114

100115
qck_it(@"should send the last value", ^{
101116
id firstValue = @"blah";

0 commit comments

Comments
 (0)