0caaf681d8
Harden live log init with safe per-entry decrypt, stable loading state, and no parallel list scan in live mode. Improve multi-sail picker UX, stop WebAuthn retry after user cancel, redirect 127.0.0.1 to localhost, and tolerate missing appearance prefs table. Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
dedupeSailNames,
|
|
isSailInSelection,
|
|
joinSailSelection,
|
|
splitSailSelection,
|
|
toggleSailInSelection
|
|
} from './sailSelection.js'
|
|
|
|
describe('toggleSailInSelection', () => {
|
|
it('adds a second sail without removing the first', () => {
|
|
const first = toggleSailInSelection([], 'Mainsail')
|
|
expect(first).toEqual(['Mainsail'])
|
|
const second = toggleSailInSelection(first, 'Genoa')
|
|
expect(second).toEqual(['Mainsail', 'Genoa'])
|
|
})
|
|
|
|
it('removes sail when toggled again', () => {
|
|
const selected = toggleSailInSelection(
|
|
toggleSailInSelection([], 'Mainsail'),
|
|
'Genoa'
|
|
)
|
|
expect(toggleSailInSelection(selected, 'Mainsail')).toEqual(['Genoa'])
|
|
})
|
|
|
|
it('matches case-insensitively', () => {
|
|
expect(toggleSailInSelection(['genua'], 'Genua')).toEqual([])
|
|
expect(isSailInSelection(['Großsegel'], 'großsegel')).toBe(true)
|
|
})
|
|
})
|
|
|
|
describe('joinSailSelection / splitSailSelection', () => {
|
|
it('round-trips multiple sails', () => {
|
|
const joined = joinSailSelection(['Großsegel', 'Genua'])
|
|
expect(joined).toBe('Großsegel + Genua')
|
|
expect(splitSailSelection(joined)).toEqual(['Großsegel', 'Genua'])
|
|
})
|
|
})
|
|
|
|
describe('dedupeSailNames', () => {
|
|
it('removes duplicate names', () => {
|
|
expect(dedupeSailNames(['Genua', 'genua', 'Fock'])).toEqual(['Genua', 'Fock'])
|
|
})
|
|
})
|