Closed DanweDE closed 4 years ago
No, that's correct. A never
stream has a current value of end
. That's a Kefir behavior, and it makes sense because a never
stream is currently ended.
So the expect(stream).toEmit([kefirHelpers.end()]);
line of the test is very unintuitive.
Why does kefirHelpers.end()
include current: false
then? Aren't all observables that ended currently ended? Thus type: "end"
should always come with current: true
, or am I missing something?
No. You could write a test like this:
const a = stream();
expect(a).toEmit([value(1), end()], () => {
send(a, [value(1), end()]);
});
At the point the stream is subscribed, it is not ended. It emits an end later.
Also, to be clear, current
is only relevant to Properties. Kefir has 2 Observable subtypes: Property & Stream, with Property being the one with a concept of current value. More info is in the docs: https://kefirjs.github.io/kefir/#about-observables
If current
is only relevant to properties, then couldn't we just ignore current
if the given observable is a stream and thus make
const stream = K.never();
expect(stream).toEmit([kefirHelpers.end()]);
pass? :thinking:
K.never
returns a Property with a current value of end
. That's all it is. This passes:
const stream = K.never();
expect(stream).toEmit([kefirHelpers.end({ current: true })]);
if you're trying to get the test to pass. Otherwise, everything is functioning as expected.
I am using kefir-test-utils through https://github.com/kefirjs/jest-kefir and noticed the following failure:
with the FAILURE being:
Not sure why
current: false
is expected here, can anyone explain or confirm that this is a bug? Using Kefir 3.8.6 and latest version of testing packages as well.