Skip to content

Commit

Permalink
fix(tests): make size checks more graceful for yjs
Browse files Browse the repository at this point in the history
Internal changes can change the size of the resulting documents.
Only fail the tests if it changes significantly.

Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Jul 28, 2023
1 parent 35afacd commit a8c9ec6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/tests/yjs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ describe('recorded session', () => {
expect(length).toBe(0)
}
})
expect(encodeStateAsUpdate(ydoc).length).toBe(34503)
expect(encodeStateAsUpdate(ydoc).length).toBeGreaterThan(30000)
expect(encodeStateAsUpdate(ydoc).length).toBeLessThan(40000)
})

test('analyse responses', () => {
Expand All @@ -114,7 +115,8 @@ describe('recorded session', () => {
})
const replies = responses.filter(r => r.length)
expect(replies.length).toBe(344)
expect(size(replies)).toBe(562868)
expect(size(replies)).toBeGreaterThan(500000)
expect(size(replies)).toBeLessThan(600000)
})

test('leaving out queries', () => {
Expand All @@ -133,7 +135,8 @@ describe('recorded session', () => {
}
})
const replies = responses.filter(r => r.length)
expect(encodeStateAsUpdate(ydoc).length).toBe(34503)
expect(encodeStateAsUpdate(ydoc).length).toBeGreaterThan(30000)
expect(encodeStateAsUpdate(ydoc).length).toBeLessThan(40000)
expect(replies.length).toBe(0)
expect(size(replies)).toBe(0)
})
Expand Down

0 comments on commit a8c9ec6

Please sign in to comment.