mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-22 13:32:11 +00:00
Squashed cherry-pick of PR #11811. Amp-Thread-ID: https://ampcode.com/threads/T-019df514-1f1c-7764-aa92-76b65210a74d Co-authored-by: Amp <amp@ampcode.com>
26 lines
845 B
TypeScript
26 lines
845 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { makeCompositeKey } from './compositeKey'
|
|
|
|
describe('makeCompositeKey', () => {
|
|
it('produces a stable string for a tuple of values', () => {
|
|
expect(makeCompositeKey(['a', 'b', 'c'])).toBe('["a","b","c"]')
|
|
})
|
|
|
|
it('distinguishes tuples whose joined parts collide', () => {
|
|
// Without an injective encoding, ['ab', 'c'] and ['a', 'bc'] could collide.
|
|
expect(makeCompositeKey(['ab', 'c'])).not.toBe(
|
|
makeCompositeKey(['a', 'bc'])
|
|
)
|
|
})
|
|
|
|
it('handles empty parts and undefined slots', () => {
|
|
expect(makeCompositeKey(['x', '', 'y'])).toBe('["x","","y"]')
|
|
expect(makeCompositeKey(['x', undefined, 'y'])).toBe('["x",null,"y"]')
|
|
})
|
|
|
|
it('preserves part order', () => {
|
|
expect(makeCompositeKey(['1', '2'])).not.toBe(makeCompositeKey(['2', '1']))
|
|
})
|
|
})
|