Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
anis committed Sep 12, 2024
1 parent f3933de commit 4eced78
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 5 deletions.
68 changes: 67 additions & 1 deletion packages/common/src/sections.test.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
8 changes: 4 additions & 4 deletions packages/common/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down

0 comments on commit 4eced78

Please sign in to comment.