mirror of
https://github.com/IliesAllali/parenthese.git
synced 2026-11-17 00:33:28 +00:00
test(kinship): shared helpers instead of importing a test file
Importing `path` from kinship.fr.test.js made Vitest run the French tests a second time inside kinship.en.test.js (18 tests instead of 10). `path` and a `namesBySex(lang)` helper now live in test-helpers.js, which the test include pattern ignores. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: IliesAllali <pro.allali.ilies@gmail.com>
This commit is contained in:
1 parent
af3a388db8
commit
b806661d9b
3 files changed
+16
-9
No files matched your search
@@ -1,8 +1,8 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { nameKinship } from './index.js'
|
||||
import { path } from './kinship.fr.test.js'
|
||||
import { path, namesBySex } from './test-helpers.js'
|
||||
|
||||
const both = (moves) => ['male', 'female', null].map((sex) => nameKinship(path(moves, sex), 'en'))
|
||||
const both = namesBySex('en')
|
||||
|
||||
describe('nommage anglais', () => {
|
||||
it('genre le mot quand le sexe est connu', () => {
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { kinshipFacts, nameKinship, normalizeSex } from './index.js'
|
||||
import { computeRelationshipLabel, kinshipPath } from '../../components/galaxy/pathfinding.js'
|
||||
import { path, namesBySex } from './test-helpers.js'
|
||||
|
||||
// Chemin écrit à la main : moves = suite de pas, sex = sexe de la personne au bout
|
||||
export const path = (moves, sex = null, extra = {}) => ({
|
||||
from: { id: 'moi', sex: null, birthYear: null },
|
||||
steps: moves.map((move, i) => ({ move, person: { id: `p${i}`, sex: i === moves.length - 1 ? sex : null, birthYear: null, ...(extra[i] || {}) } })),
|
||||
})
|
||||
|
||||
const both = (moves) => ['male', 'female', null].map((sex) => nameKinship(path(moves, sex), 'fr'))
|
||||
const both = namesBySex('fr')
|
||||
|
||||
describe('nommage français', () => {
|
||||
it('genre le mot quand le sexe est connu, garde la forme double sinon', () => {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Partagé par les fichiers kinship.<langue>.test.js. Ce n'est pas un fichier de test :
|
||||
// Vitest ne le ramasse pas (include: src/**/*.test.{js,jsx}).
|
||||
import { nameKinship } from './index.js'
|
||||
|
||||
// Chemin écrit à la main : moves = suite de pas, sex = sexe de la personne au bout
|
||||
export const path = (moves, sex = null, extra = {}) => ({
|
||||
from: { id: 'moi', sex: null, birthYear: null },
|
||||
steps: moves.map((move, i) => ({ move, person: { id: `p${i}`, sex: i === moves.length - 1 ? sex : null, birthYear: null, ...(extra[i] || {}) } })),
|
||||
})
|
||||
|
||||
// Nomme le même chemin pour un homme, une femme et un sexe non précisé au bout
|
||||
export const namesBySex = (lang) => (moves) => ['male', 'female', null].map((sex) => nameKinship(path(moves, sex), lang))
|
||||
Reference in new issue
Block a user