snapshot of https://github.com/tldraw/tldraw.git (main, 2026-09-23; blobs > 131072B omitted)
Some checks failed
Deploy analytics worker / Deploy analytics worker to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
i18n upload strings / Upload latest strings (push) Failing after 1s
Deploy bemo / Deploy bemo to ${{ (github.ref == 'refs/heads/bemo-production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
Deploy grafana resources / ${{ github.event_name == 'push' && 'Deploy grafana resources' || 'Validate grafana resources (dry run)' }} (push) Failing after 0s
End to end tests (dotcom) / Check for relevant changes (push) Failing after 0s
End to end tests (examples) / Check for relevant changes (push) Failing after 0s
End to end tests (mermaid readability) / Check for relevant changes (push) Failing after 1s
End to end tests (perf) / Check for relevant changes (push) Failing after 0s
Publish editor extensions / Publish editor extensions (push) Failing after 1s
Publish SDK packages / Remove the publish-packages label (push) Has been skipped
Checks / Tests & checks (push) Has been cancelled
Checks / Build all projects (push) Has been cancelled
Deploy templates / Deploy templates (push) Has been cancelled
End to end tests (dotcom) / End to end tests (dotcom) (push) Has been cancelled
End to end tests (mermaid readability) / End to end tests (mermaid readability) (push) Has been cancelled
End to end tests (perf) / End to end tests (perf) (push) Has been cancelled
Deploy .com / Deploy dotcom to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Has been cancelled
End to end tests (examples) / End to end tests (examples) (push) Has been cancelled
Publish SDK packages / Publish SDK packages (push) Has been cancelled
Publish SDK packages / Tell user released version (push) Has been cancelled
Publish SDK packages / Publishes code templates to separate repositories (push) Has been cancelled
Publish SDK packages / Deploys the template demos with the new SDK version (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-23 16:12:52 +05:00
commit a774ac673a
4541 changed files with 770499 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
import { describe, expect, it } from 'vitest'
import { diffSets, intersectSets } from './setUtils'
// Tests for SPEC.md §25 (set utilities).
// Rule IDs like [SU1] in test names refer to that document.
describe('intersectSets (SU)', () => {
it('[SU1] returns the elements present in every set', () => {
expect(
intersectSets([new Set([1, 2, 3, 4]), new Set([2, 3, 4, 5]), new Set([3, 4, 5, 6])])
).toEqual(new Set([3, 4]))
expect(intersectSets([new Set([1, 2, 3]), new Set([4, 5, 6])])).toEqual(new Set())
expect(intersectSets([new Set([1, 2, 3]), new Set(), new Set([2, 3, 4])])).toEqual(new Set())
})
it('[SU1] no sets yields an empty set', () => {
expect(intersectSets([])).toEqual(new Set())
})
it('[SU1] a single set yields a copy', () => {
const set = new Set([1, 2, 3])
const result = intersectSets([set])
expect(result).not.toBe(set)
expect(result).toEqual(set)
})
})
describe('diffSets (SU)', () => {
it('[SU2] reports added and removed elements, with only the populated keys', () => {
expect(diffSets(new Set(['a', 'b']), new Set(['a', 'b', 'c']))).toEqual({
added: new Set(['c']),
})
expect(diffSets(new Set(['a', 'b', 'c']), new Set(['a', 'b']))).toEqual({
removed: new Set(['c']),
})
expect(diffSets(new Set(['a', 'b']), new Set(['b', 'c']))).toEqual({
added: new Set(['c']),
removed: new Set(['a']),
})
})
it('[SU2] returns undefined when the sets have the same members', () => {
expect(diffSets(new Set(['a', 'b', 'c']), new Set(['a', 'b', 'c']))).toBeUndefined()
expect(diffSets(new Set(), new Set())).toBeUndefined()
})
it('[SU2] compares object members by reference', () => {
const obj1 = { id: 1 }
const obj2 = { id: 2 }
const obj3 = { id: 3 }
expect(diffSets(new Set([obj1, obj2]), new Set([obj2, obj3]))).toEqual({
added: new Set([obj3]),
removed: new Set([obj1]),
})
// structurally equal but distinct objects are different members
expect(diffSets(new Set([{ id: 1 }]), new Set([{ id: 1 }]))).toBeDefined()
})
})