mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 06:43:06 +00:00
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { ACERVO_SORT_OPTIONS, acervoSortIsDuration, parseAcervoSort } from '@/lib/acervoListSort'
|
|
|
|
// C216 — the shared ordering vocabulary of the acervo (recordings C219 + web
|
|
// speeches): `recentes` is the default and never serialized, and only the two
|
|
// duration orders count as duration sorts (the `where` gate follows them).
|
|
|
|
describe('parseAcervoSort', () => {
|
|
it('accepts only the non-default known orders', () => {
|
|
expect(parseAcervoSort('duracao_maior')).toBe('duracao_maior')
|
|
expect(parseAcervoSort('duracao_menor')).toBe('duracao_menor')
|
|
expect(parseAcervoSort('recentes')).toBeUndefined()
|
|
expect(parseAcervoSort('maratona')).toBeUndefined()
|
|
expect(parseAcervoSort(undefined)).toBeUndefined()
|
|
expect(parseAcervoSort(['duracao_maior', 'duracao_menor'])).toBe('duracao_maior')
|
|
})
|
|
})
|
|
|
|
describe('acervoSortIsDuration', () => {
|
|
it('flags only the duration orders', () => {
|
|
expect(acervoSortIsDuration('duracao_maior')).toBe(true)
|
|
expect(acervoSortIsDuration('duracao_menor')).toBe(true)
|
|
expect(acervoSortIsDuration('recentes')).toBe(false)
|
|
expect(acervoSortIsDuration(undefined)).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('ACERVO_SORT_OPTIONS', () => {
|
|
it('keeps the pt-BR labels of the approved control', () => {
|
|
expect(ACERVO_SORT_OPTIONS).toEqual([
|
|
{ value: 'recentes', label: 'Mais recentes' },
|
|
{ value: 'duracao_maior', label: 'Duração (maior)' },
|
|
{ value: 'duracao_menor', label: 'Duração (menor)' },
|
|
])
|
|
})
|
|
})
|