Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,24 @@ const awarenessFrame = (expiresAt: unknown) => ({

const sequencedFrame = (
type: 'doc_subscribed' | 'doc_reset',
seq?: unknown
seq: unknown
Comment thread
christian-byrne marked this conversation as resolved.
Resolved
Comment thread
christian-byrne marked this conversation as resolved.
Resolved
) => ({
type,
data: {
v: 1,
workflow_id: 'wf-1',
...(seq !== undefined && { seq }),
seq,
...(type === 'doc_subscribed' && { ok: true })
}
})

function unsequencedSubscribedFrame() {
return {
type: 'doc_subscribed',
data: { v: 1, workflow_id: 'wf-1', ok: true }
}
}

const docOpsResultFrame = (seq?: unknown) => ({
type: 'doc_ops_result',
data: {
Expand Down Expand Up @@ -90,10 +97,12 @@ describe('doc frame numeric domains', () => {
)

it('accepts doc_subscribed without seq', () => {
expect(parseServerDocFrame(sequencedFrame('doc_subscribed'))).toEqual({
const frame = parseServerDocFrame(unsequencedSubscribedFrame())
expect(frame).toEqual({
type: 'doc_subscribed',
data: { workflowId: 'wf-1', ok: true }
})
expect(frame?.data).not.toHaveProperty('seq')
Comment thread
christian-byrne marked this conversation as resolved.
Resolved
})

it.for([-1, 1.5, Number.POSITIVE_INFINITY, Number.NaN, '1'])(
Expand Down
Loading