Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't treat notifier completion as a signal #5853

Merged
merged 7 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions spec/operators/audit-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('audit operator', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot(' -a-xy-----b--x--cxxx-|');
const e1subs = ' ^--------------------!';
const e2 = cold(' ----| ');
const e2 = cold(' ----x ');
const e2subs = [
' -^---! ',
' ----------^---! ',
Expand All @@ -36,7 +36,7 @@ describe('audit operator', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot(' -a--------b-----c----|');
const e1subs = ' ^--------------------!';
const e2 = cold(' ----| ');
const e2 = cold(' ----x ');
const e2subs = [
' -^---! ',
' ----------^---! ',
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('audit operator', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot(' abcdefabcdefabcdefabcdefa| ');
const e1subs = ' ^------------------------! ';
const e2 = cold(' -----| ');
const e2 = cold(' -----x ');
const e2subs = [
' ^----! ',
' ------^----! ',
Expand All @@ -140,11 +140,11 @@ describe('audit operator', () => {
});
});

it('should mirror source if durations are always empty', () => {
it('should mirror source if durations are immediate', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot(' abcdefabcdefabcdefabcdefa|');
const e1subs = ' ^------------------------!';
const e2 = cold(' |');
const e2 = cold(' x');
const expected = 'abcdefabcdefabcdefabcdefa|';

const result = e1.pipe(audit(() => e2));
Expand All @@ -154,12 +154,12 @@ describe('audit operator', () => {
});
});

it('should mirror source if durations are EMPTY', () => {
it('should emit no values if durations are EMPTY', () => {
testScheduler.run(({ hot, expectObservable, expectSubscriptions }) => {
const e1 = hot('abcdefabcdefabcdefabcdefa|');
const e1subs = '^------------------------!';
const e2 = EMPTY;
const expected = 'abcdefabcdefabcdefabcdefa|';
const expected = '-------------------------|';

const result = e1.pipe(audit(() => e2));

Expand Down Expand Up @@ -235,11 +235,11 @@ describe('audit operator', () => {
const e1 = hot(' abcdefabcdabcdefghabca| ');
const e1subs = ' ^---------------------! ';
const e2 = [
cold(' -----| '),
cold(' ---| '),
cold(' -------| '),
cold(' --| '),
cold(' ----| ')
cold(' -----x '),
cold(' ---x '),
cold(' -------x '),
cold(' --x '),
cold(' ----x ')
];
const e2subs = [
' ^----! ',
Expand All @@ -266,8 +266,8 @@ describe('audit operator', () => {
const e1 = hot(' abcdefabcdabcdefghabca|');
const e1subs = ' ^----------------! ';
const e2 = [
cold(' -----| '),
cold(' ---| '),
cold(' -----x '),
cold(' ---x '),
cold(' -------# ')
];
const e2subs = [
Expand All @@ -293,13 +293,13 @@ describe('audit operator', () => {
const e1 = hot('abcdefabcdabcdefghabca| ');
const e1subs = '^---------! ';
const e2 = [
cold(' -----| '),
cold(' ---| '),
cold(' -------| ')
cold(' -----x '),
cold(' ---x '),
cold(' -------x ')
];
const e2subs = [
' ^----! ',
' ------^--! '
' ------^--! '
];
const expected = '-----f---d# ';

Expand Down Expand Up @@ -458,7 +458,7 @@ describe('audit operator', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot('-a--------xy| ');
const e1subs = ' ^-----------! ';
const e2 = cold(' ----| ');
const e2 = cold(' ----x ');
const e2subs = [
' -^---! ',
' ----------^---!'
Expand Down
115 changes: 62 additions & 53 deletions spec/operators/bufferToggle-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ describe('bufferToggle operator', () => {

it('should emit buffers using varying cold closings', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot('--a--^---b---c---d---e---f---g---h------| ');
const e2 = cold(' --x-----------y--------z---| ');
const subs = ' ^----------------------------------! ';
const e1 = hot('--a--^---b---c---d---e---f---g---h------| ');
const e2 = cold(' --x-----------y--------z---| ');
const subs = ' ^----------------------------------! ';
const closings = [
cold(' ---------------s--| '),
cold(' ----(s|) '),
cold(' ---------------(s|)')
cold(' ---------------s--| '),
cold(' ----(s|) '),
cold(' ---------------(s|)')
];
const closeSubs = [
' --^--------------! ',
' --------------^---! ',
' -----------------------^-----------! '
' --^--------------! ',
' --------------^---! ',
' -----------------------^-----------! '
];
const expected = '-----------------ij----------------(k|) ';
const expected = ' -----------------ij----------------(k|) ';
const values = {
i: ['b', 'c', 'd', 'e'],
j: ['e'],
Expand Down Expand Up @@ -100,11 +100,11 @@ describe('bufferToggle operator', () => {
sub: ' --^--------------! '
},
{
obs: hot(' -----3----4-------(s|) '),
obs: hot(' -----3----4-------(s|) '),
sub: ' --------------^---! '
},
{
obs: hot(' -------3----4-------5----------------s| '),
obs: hot(' -------3----4-------5----------------s|'),
sub: ' -----------------------^-----------! '
}
];
Expand All @@ -129,18 +129,18 @@ describe('bufferToggle operator', () => {

it('should emit buffers using varying empty delayed closings', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot('--a--^---b---c---d---e---f---g---h------| ');
const e2 = cold(' --x-----------y--------z---| ');
const subs = ' ^----------------------------------! ';
const e1 = hot('--a--^---b---c---d---e---f---g---h------| ');
const e2 = cold(' --x-----------y--------z---| ');
const subs = ' ^----------------------------------! ';
const closings = [
cold(' ---------------| '),
cold(' ----| '),
cold(' ---------------| ')
cold(' ---------------| '),
cold(' ----| '),
cold(' ---------------| ')
];
const expected = ' -----------------ij----------------(k|)';
const expected = ' -----------------------------------(ijk|)';
const values = {
i: ['b', 'c', 'd', 'e'],
j: ['e'],
i: ['b', 'c', 'd', 'e', 'f', 'g', 'h'],
j: ['e', 'f', 'g', 'h'],
k: ['g', 'h']
};

Expand All @@ -158,9 +158,9 @@ describe('bufferToggle operator', () => {
const subs = ' ^---------! ';
const e2 = cold(' --x-----------y--------z---| ');
const closings = [
cold(' ---------------s--| '),
cold(' ----(s|) '),
cold(' ---------------(s|) ')
cold(' ---------------s--| '),
cold(' ----(s|) '),
cold(' ---------------(s|)')
];
const csub0 = ' --^-------! ';
const expected = ' ----------- ';
Expand All @@ -182,16 +182,16 @@ describe('bufferToggle operator', () => {

it('should not break unsubscription chains when result is unsubscribed explicitly', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot('--a--^---b---c---d---e---f---g---h------| ');
const subs = ' ^-----------------! ';
const e2 = cold(' --x-----------y--------z---| ');
const e1 = hot('--a--^---b---c---d---e---f---g---h------| ');
const subs = ' ^-----------------! ';
const e2 = cold(' --x-----------y--------z---| ');
const closings = [
cold(' ---------------s--| '),
cold(' ----(s|) '),
cold(' ---------------(s|)')
cold(' ---------------s--| '),
cold(' ----(s|) '),
cold(' ---------------(s|)')
];
const expected = ' -----------------i- ';
const unsub = ' ------------------! ';
const expected = ' -----------------i- ';
const unsub = ' ------------------! ';
const values = {
i: ['b', 'c', 'd', 'e']
};
Expand All @@ -210,16 +210,16 @@ describe('bufferToggle operator', () => {

it('should propagate error thrown from closingSelector', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot('--a--^---b---c---d---e---f---g---h------| ');
const e2 = cold(' --x-----------y--------z---| ');
const subs = ' ^-------------! ';
const e1 = hot('--a--^---b---c---d---e---f---g---h------| ');
const e2 = cold(' --x-----------y--------z---| ');
const subs = ' ^-------------! ';
const closings = [
cold(' ---------------s--| '),
cold(' ----(s|) '),
cold(' ---------------(s|)')
cold(' ---------------s--| '),
cold(' ----(s|) '),
cold(' ---------------(s|)')
];
const closeSubs0 = '--^-----------! ';
const expected = '--------------# ';
const closeSubs0 = ' --^-----------! ';
const expected = ' --------------# ';

let i = 0;
const result = e1.pipe(
Expand All @@ -245,10 +245,10 @@ describe('bufferToggle operator', () => {
const e2 = cold(' --x-----------y--------z---| ');
const subs = ' ^-------------! ';
const closings = [
cold(' ---------------s--| '),
cold(' # ')
cold(' ---------------s--| '),
cold(' # ')
];
const closeSubs = [
const closeSubs = [
' --^-----------! ',
' --------------(^!) '
];
Expand All @@ -270,8 +270,8 @@ describe('bufferToggle operator', () => {
const e2 = cold(' --x-----------y--------z---| ');
const subs = ' ^------------------! ';
const closings = [
cold(' ---------------s--| '),
cold(' -----# ')
cold(' ---------------s--| '),
cold(' -----# ')
];
const closeSubs = [
' --^--------------! ',
Expand All @@ -298,10 +298,10 @@ describe('bufferToggle operator', () => {
const e2 = cold(' --x-----------y--------z---|');
const subs = ' ^------------------! ';
const closings = [
cold(' ---------------s--| '),
cold(' -------s| ')
cold(' ---------------s--| '),
cold(' -------s| ')
];
const closeSubs = [
const closeSubs = [
' --^--------------! ',
' --------------^----! '
];
Expand Down Expand Up @@ -353,6 +353,10 @@ describe('bufferToggle operator', () => {
const e1 = hot(' -');
const e2 = cold(' --o-----o------o-----o---o-----|');
const e3 = cold(' --c-|');
// --c-|
// --c-|
// --c-|
// --c-|
const unsub = ' --------------------------------------------!';
const subs = ' ^-------------------------------------------!';
const expected = '----x-----x------x-----x---x-----------------';
Expand Down Expand Up @@ -500,14 +504,19 @@ describe('bufferToggle operator', () => {

it('should handle empty closing observable', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot('--a--^---b---c---d---e---f---g---h------|');
const subs = ' ^----------------------------------!';
const e2 = cold(' --x-----------y--------z---| ');
const expected = ' --l-----------m--------n-----------|';
const e1 = hot('--a--^---b---c---d---e---f---g---h------| ');
const subs = ' ^----------------------------------! ';
const e2 = cold(' --x-----------y--------z---| ');
const expected = ' -----------------------------------(ijk|)';
const values = {
i: ['b', 'c', 'd', 'e', 'f', 'g', 'h'],
j: ['e', 'f', 'g', 'h'],
k: ['g', 'h']
};

const result = e1.pipe(bufferToggle(e2, () => EMPTY));

expectObservable(result).toBe(expected, {l: [], m: [], n: []});
expectObservable(result).toBe(expected, values);
expectSubscriptions(e1.subscriptions).toBe(subs);
});
});
Expand Down
18 changes: 8 additions & 10 deletions spec/operators/bufferWhen-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('bufferWhen operator', () => {
});
});

it('should emit buffers using varying empty delayed closings', () => {
it('should not emit buffers using varying empty delayed closings', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const e1 = hot('--a--^---b---c---d---e---f---g---h------| ');
const subs = ' ^----------------------------------! ';
Expand All @@ -98,14 +98,12 @@ describe('bufferWhen operator', () => {
];
const closeSubs = [
' ^--------------! ',
' ---------------^---------! ',
' -------------------------^---------! '
' ',
' ',
];
const expected = ' ---------------x---------y---------(z|)';
const expected = ' -----------------------------------(x|)';
const values = {
x: ['b', 'c', 'd'],
y: ['e', 'f', 'g'],
z: ['h']
x: ['b', 'c', 'd', 'e', 'f', 'g', 'h']
};

let i = 0;
Expand Down Expand Up @@ -359,13 +357,13 @@ describe('bufferWhen operator', () => {
});
});

// bufferWhen is not supposed to handle a factory that returns always empty
// bufferWhen is not supposed to handle a factory that returns always sync
// closing Observables, because doing such would constantly recreate a new
// buffer in a synchronous infinite loop until the stack overflows. This also
// happens with buffer in RxJS 4.
it('should NOT handle hot inner empty', (done: MochaDone) => {
it('should NOT handle synchronous inner', (done: MochaDone) => {
const source = of(1, 2, 3, 4, 5, 6, 7, 8, 9);
const closing = EMPTY;
const closing = of(1);
const TOO_MANY_INVOCATIONS = 30;

source.pipe(
Expand Down
Loading