From 4eced788a26905b65b9f387b756fbc3a1c9cec94 Mon Sep 17 00:00:00 2001 From: Anis Safine Laget Date: Thu, 12 Sep 2024 18:05:34 +0200 Subject: [PATCH] rebase --- packages/common/src/sections.test.ts | 68 +++++++++++++++++++++++++++- packages/common/vitest.config.ts | 8 ++-- 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/packages/common/src/sections.test.ts b/packages/common/src/sections.test.ts index cc143bd92..851139006 100644 --- a/packages/common/src/sections.test.ts +++ b/packages/common/src/sections.test.ts @@ -1,7 +1,73 @@ import { test, expect } from 'vitest' -import { simpleContenuToFlattenedContenu } from './sections' +import { isRadioElement, simpleContenuToFlattenedContenu, valeurFind } from './sections' import { caminoDateValidator } from './date' +test('valeurFind', () => { + expect(valeurFind({ id: 'camino', type: 'text', value: null, optionnel: false })).toBe('–') + expect(valeurFind({ id: 'camino', type: 'text', value: '', optionnel: false })).toBe('–') + expect(valeurFind({ id: 'camino', type: 'integer', value: 0, optionnel: false })).toBe('0') + expect(valeurFind({ id: 'camino', type: 'number', value: 0, optionnel: false })).toBe('0') + expect( + valeurFind({ + id: 'camino', + type: 'checkboxes', + value: ['a', 'b'], + options: [ + { id: 'a', nom: 'A' }, + { id: 'b', nom: 'B' }, + ], + optionnel: false, + }) + ).toBe('A, B') + expect( + valeurFind({ + id: 'camino', + type: 'checkboxes', + value: [], + options: [ + { id: 'a', nom: 'A' }, + { id: 'b', nom: 'B' }, + ], + optionnel: false, + }) + ).toBe('–') + expect( + valeurFind({ + id: 'camino', + type: 'select', + value: 'a', + options: [ + { id: 'a', nom: 'A' }, + { id: 'b', nom: 'B' }, + ], + optionnel: false, + }) + ).toBe('A') + expect( + valeurFind({ + id: 'camino', + type: 'select', + value: 'c', + options: [ + { id: 'a', nom: 'A' }, + { id: 'b', nom: 'B' }, + ], + optionnel: false, + }) + ).toBe('-') + expect(valeurFind({ id: 'camino', type: 'date', value: caminoDateValidator.parse('2000-01-01'), optionnel: false })).toBe('01-01-2000') + expect(valeurFind({ id: 'camino', type: 'radio', value: true, optionnel: false })).toBe('Oui') + expect(valeurFind({ id: 'camino', type: 'radio', value: false, optionnel: false })).toBe('Non') + expect(valeurFind({ id: 'camino', type: 'checkbox', value: true, optionnel: false })).toBe('Oui') + expect(valeurFind({ id: 'camino', type: 'checkbox', value: false, optionnel: false })).toBe('Non') + expect(valeurFind({ id: 'camino', type: 'url', value: 'test', optionnel: false })).toBe('test') +}) + +test('isRadioElement', () => { + expect(isRadioElement({ id: 'camino', type: 'radio', value: false, optionnel: false })).toBe(true) + expect(isRadioElement({ id: 'camino', type: 'text', value: '', optionnel: false })).toBe(false) +}) + test('simpleContenuToFlattenedContenu', () => { expect( simpleContenuToFlattenedContenu( diff --git a/packages/common/vitest.config.ts b/packages/common/vitest.config.ts index 6343ed63e..f08063321 100644 --- a/packages/common/vitest.config.ts +++ b/packages/common/vitest.config.ts @@ -10,10 +10,10 @@ export default defineConfig({ thresholds: { // the endgame is to put thresholds at 100 and never touch it again :) autoUpdate: true, - branches: 90.95, - functions: 82.67, - lines: 96.51, - statements: 96.51, + branches: 91.01, + functions: 83.46, + lines: 96.68, + statements: 96.68, perFile: false, }, },