Skip to content

Commit

Permalink
Add test for ReplaySubject that returns correct values while subscrip…
Browse files Browse the repository at this point in the history
…tion is made in another subscription
  • Loading branch information
Aleksei Minaev committed Mar 28, 2019
1 parent 74ab5ba commit 35aa8e4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ReactiveObjCTests/RACSubjectSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ - (void)didSubscribeWithDisposable:(RACCompoundDisposable *)disposable {
qck_beforeEach(^{
subject = [RACReplaySubject replaySubjectWithCapacity:1];
});

qck_it(@"should send same latest value to multiple subscribers in another subscription", ^{
__block NSMutableArray *values = [NSMutableArray array];

[subject subscribeNext:^(id _Nullable item1) {
[values addObject:item1];
[[subject take:1] subscribeNext:^(id _Nullable item2) {
[values addObject:item2];
}];
}];
[subject sendNext:@1];
[subject sendNext:@2];

expect(values).to(equal(@[@1, @1, @2, @2]));
});

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

0 comments on commit 35aa8e4

Please sign in to comment.