Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

temporal-group-key.test.ts

25 lines1.1 KB

1import { Temporal } from 'temporal-polyfill'
2import { describe, expect, it } from 'vitest'
3import { serializeValue } from '../src/index.js'
4​
5// Ordinary tests for Temporal group keys: serialized identity of Temporal
6// values inside plain objects, arrays, Maps, and Sets. The grouping law
7// belongs to temporal-group-key-oracle.test.ts.
8describe('Temporal group keys', () => {
9 it('keeps a Temporal value distinct from an empty object', () => {
10 const date = Temporal.PlainDate.from('2024-01-15')
11 const anotherDate = Temporal.PlainDate.from('2024-06-15')
12 expect(serializeValue(date)).not.toBe(serializeValue({}))
13 expect(serializeValue(date)).not.toBe(serializeValue(date.toString()))
14 expect(serializeValue({ date })).not.toBe(serializeValue({ date: {} }))
15 expect(serializeValue({ dates: [date] })).not.toBe(
16 serializeValue({ dates: [anotherDate] }),
17 )
18 expect(serializeValue(new Map([['date', date]]))).not.toBe(
19 serializeValue(new Map([['date', anotherDate]])),
20 )
21 expect(serializeValue(new Set([date]))).not.toBe(
22 serializeValue(new Set([anotherDate])),
23 )
24 })
25})