Skip to content

Commit 9cd8251

Browse files
authored
Normalize watchWithTime (#357)
* Normalize watchWithTime Closes #4 * Convert some let to const
1 parent 03d5037 commit 9cd8251

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,10 @@ export default function createTestHelpers(Kefir) {
205205
const log = []
206206
let isCurrent = true
207207
const fn = event => log.push([+new Date() - startTime, logItem(event, isCurrent)])
208-
// const unwatch = () => obs.offAny(fn)
208+
const unwatch = () => obs.offAny(fn)
209209
obs.onAny(fn)
210210
isCurrent = false
211-
212-
// Using the array directly is deprecated.
213-
// Use the log & unwatch properties instead.
214-
// The return will match `watch` in v2.0.0.
215-
// log.log = log
216-
// log.unwatch = unwatch
217-
return log
211+
return {log, unwatch}
218212
}
219213

220214
const observables = {

test/kefir-test-utils.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,10 @@ describe('kefir-test-utils', () => {
213213
})
214214

215215
describe('sendFrames', () => {
216-
let log, obs, oldErr
216+
let log
217+
const {Error: oldErr} = global
217218

218219
beforeEach(() => {
219-
obs = stream()
220-
oldErr = global.Error
221220
global.Error = class Error {}
222221
})
223222

@@ -226,6 +225,7 @@ describe('kefir-test-utils', () => {
226225
})
227226

228227
it('should send diagram to observable', () => {
228+
const obs = stream()
229229
const events = {
230230
a: [value(0), value(1)],
231231
b: [value(2)],
@@ -234,7 +234,7 @@ describe('kefir-test-utils', () => {
234234
}
235235

236236
withFakeTime(tick => {
237-
log = watchWithTime(obs)
237+
log = watchWithTime(obs).log
238238

239239
sendFrames(obs, {
240240
frames: parseDiagram('ab-c--d---#----7-e|---f', events),
@@ -356,7 +356,7 @@ describe('kefir-test-utils', () => {
356356
it('should log values emitted by stream', () => {
357357
withFakeTime(() => {
358358
const obs = stream()
359-
const log = watchWithTime(obs)
359+
const {log} = watchWithTime(obs)
360360
send(obs, [value(1), error(2), end()])
361361
expect(log).to.deep.equal([
362362
[0, value(1)],
@@ -366,7 +366,7 @@ describe('kefir-test-utils', () => {
366366
})
367367
})
368368

369-
it.skip('should not log values emitted by stream after unwatch', () => {
369+
it('should not log values emitted by stream after unwatch', () => {
370370
const obs = stream()
371371
const {log, unwatch} = watchWithTime(obs)
372372
unwatch()

0 commit comments

Comments
 (0)