mirror of
https://github.com/gramps-project/gramps-web.git
synced 2026-10-16 21:01:38 +08:00
ed4c7ccb8e
* Mudanças para resolução da issue #507, além de outros erros * Alteração dos ícones de eventos nas páginas pessoais * Contribution for the resolution of issue #507 - providing different genealogical ssymbols * Fix package-lock.json out of sync with package.json * Restore package-lock.json to match upstream, fixing missing yaml@2.9.0 * Restore package-lock.json to match upstream, fixing missing yaml@2.9.0 * Implementing recommended changes * Addressing the latest comments by Copilot * Resolving ESLint test fail * Resolving issues (cards, etc.) post refactoring of the tree views * Resolving failing unit test issue: objectDetail undefined in 'util.test.js' * Resolving ESLint error * Changes made due to recent review * Retouching the translation of abbreviations * Discarding out-of-scope changes to objectRender.js and timeline.test.js * Revert tabindex changes
72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
import {describe, it, expect} from 'vitest'
|
||
import {
|
||
getSymbols,
|
||
SYMBOL_SET_DEFAULT,
|
||
SYMBOL_SET_TEXT,
|
||
SYMBOL_SET_OPTIONS,
|
||
} from '../../src/symbols.js'
|
||
|
||
describe('getSymbols', () => {
|
||
it('returns the default unicode symbols when settings is undefined', () => {
|
||
expect(getSymbols(undefined)).toEqual({
|
||
birthSymbol: '∗',
|
||
deathSymbol: '†',
|
||
marriageSymbol: '⚭',
|
||
divorceSymbol: '⚮',
|
||
})
|
||
})
|
||
|
||
it('returns the default unicode symbols when symbolSet is not set', () => {
|
||
expect(getSymbols({})).toEqual(getSymbols({symbolSet: SYMBOL_SET_DEFAULT}))
|
||
})
|
||
|
||
it('returns text abbreviations for the "text" set', () => {
|
||
expect(getSymbols({symbolSet: SYMBOL_SET_TEXT})).toEqual({
|
||
birthSymbol: 'b.',
|
||
deathSymbol: 'd.',
|
||
marriageSymbol: 'm.',
|
||
divorceSymbol: 'div.',
|
||
})
|
||
})
|
||
|
||
it('translates text abbreviations when a translator is provided', () => {
|
||
const translations = {
|
||
'birth abbreviation\u0004b.': 'geb.',
|
||
'death abbreviation\u0004d.': 'gest.',
|
||
'marriage abbreviation\u0004m.': 'verh.',
|
||
'Divorce abbreviation\u0004div.': 'gesch.',
|
||
}
|
||
expect(
|
||
getSymbols({symbolSet: SYMBOL_SET_TEXT}, value => translations[value])
|
||
).toEqual({
|
||
birthSymbol: 'geb.',
|
||
deathSymbol: 'gest.',
|
||
marriageSymbol: 'verh.',
|
||
divorceSymbol: 'gesch.',
|
||
})
|
||
})
|
||
|
||
it('falls back to visible abbreviations when contextual translations are missing', () => {
|
||
expect(getSymbols({symbolSet: SYMBOL_SET_TEXT}, () => undefined)).toEqual({
|
||
birthSymbol: 'b.',
|
||
deathSymbol: 'd.',
|
||
marriageSymbol: 'm.',
|
||
divorceSymbol: 'div.',
|
||
})
|
||
})
|
||
|
||
it('falls back to the default set for an unknown symbolSet', () => {
|
||
expect(getSymbols({symbolSet: 'nonsense'})).toEqual(
|
||
getSymbols({symbolSet: SYMBOL_SET_DEFAULT})
|
||
)
|
||
})
|
||
})
|
||
|
||
describe('SYMBOL_SET_OPTIONS', () => {
|
||
it('has one option per symbol set, with a matching getSymbols() result', () => {
|
||
SYMBOL_SET_OPTIONS.forEach(({value}) => {
|
||
expect(getSymbols({symbolSet: value})).toBeTruthy()
|
||
})
|
||
})
|
||
})
|