testParseThenSerialize @vuqs/core/testing
Checks the other direction: serialize(parse(serialized)) equals serialized (structurally).
Usage
ts
import { codecs } from '@vuqs/core'
import { testParseThenSerialize } from '@vuqs/core/testing'
import { expect } from 'vitest'
expect(testParseThenSerialize(codecs.integer, '42')).toBe(true)
expect(() => testParseThenSerialize(codecs.integer, 'not-a-number')).toThrow()Type
ts
function testParseThenSerialize<T>(codec: Codec<T>, serialized: ParsedQueryValue): booleanParameters
codec: Codec<T>- The codec under test.
serialized: ParsedQueryValue- The codec's canonical raw form. A non-canonical input like
'007'round-trips to'7'and is reported as a mismatch by design.
- The codec's canonical raw form. A non-canonical input like
Return value
valid: booleantruewhen the round-trip succeeds. Throws ifparserejects the input, or if the re-serialized value differs.