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

Kefir test utils upgrade #411

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion extend-expect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare namespace jest {
toEmit<V, E>(events: import('kefir-test-utils').Event<V, E>[], cb?: () => void): R
toEmitInTime<V, E>(
events: import('kefir-test-utils').EventWithTime<V, E>[],
cb?: (tick: (s: number) => void, clock: import('lolex').Clock) => void,
cb?: (tick: (s: number) => void, clock: import('@sinonjs/fake-timers').Clock) => void,
opts?: {reverseSimultaneous?: boolean; timeLimit?: number}
): R
toFlowErrors<V, E>(source?: import('kefir').Observable<V, E>): R
Expand Down
2 changes: 1 addition & 1 deletion jest-kefir.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Observable, Stream, Property} from 'kefir'
import {Helpers as KHelpers, Event} from 'kefir-test-utils'
import {Clock} from 'lolex'
import {Clock} from '@sinonjs/fake-timers'

export interface Helpers extends KHelpers {
extensions: jest.ExpectExtendMap
Expand Down
100 changes: 42 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@types/jest": "^27.0.3",
"@types/kefir": "^3.0.0",
"@types/node": "^14.0.1",
"kefir-test-utils": "^1.1.1"
"kefir-test-utils": "^2.0.0"
},
"peerDependencies": {
"jest": ">=24.0.0",
Expand Down
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,16 @@ export default function jestKefir(Kefir) {
},

toEmitInTime(received, expected, cb = noop, {timeLimit = 10000, reverseSimultaneous = false} = {}) {
let log = null
let log,
unwatch = null

withFakeTime((tick, clock) => {
log = watchWithTime(received)
// prettier-ignore
({log, unwatch} = watchWithTime(received))
cb(tick, clock)
tick(timeLimit)
}, reverseSimultaneous)
unwatch()

const options = {
comment: 'Emitted values',
Expand Down