下列的
this
我决定写一篇文章
marble test
对于该操作员。
以下是一个基本测试:
it('Test lossy zip', () => {
const a = hot('a---a--------a-');
const b = hot('--b----b---b---');
const observable = zip(
a.pipe(take(1)),
b.pipe(take(1))
).pipe(
mergeMapTo(from(['1'])),
repeat()
);
const expected = cold('--1----1-----1-');
expect(observable).toBeObservable(expected);
});
该测试按预期通过。然而,当我决定发射两次这样的发射时,它失败了:
const a = hot('a---a--------a-');
const b = hot('--b----b---b---');
const observable = zip(
a.pipe(take(1)),
b.pipe(take(1))
).pipe(
mergeMapTo(from(['1', '2'])), //Here, emitting two items instead of one
repeat()
);
我希望得到的可观察结果如下所示:
const expected = cold('--(12)----(12)-----(12)-');
或者至少是这样:
const expected = cold('--12---12----12-');
这是一个错误吗
jasmine-marbles
还是我的期望错了?