mirror of
https://github.com/betagouv/mon-entreprise
synced 2025-02-10 15:05:01 +00:00
* ✨ Simplifie la lecture de l’action SET_SIMULATION - “return early” * ✨ Make automatic translation more fail-safe * 🎨 Fix visuals for Overlay component * ✨ Make Banner component more versatile * Share simulation banner * Ajout des identifiants courts pour les objectifs * Dé/sérialisation search params <-> situation & targetUnit, basée sur une logique générique (typeof) * Suppression dans l'URL des search params correspondant à des noms de règles ou identifiant courts * Banner de partage, avec modale ou Navigator.share si disponible. Co-authored-by: Alexandre Hajjar <alexandre.hajjar@gmail.com> * URL with state: remove targetUnit * serializeEvaluation for url sharing * serializeEvaluation for number, boolean, string * use this serialization in url search params * for now, no support for Objects (like localisation) Co-authored-by: Johan Girod <dev@johangirod.com> * 🖋️ Quelques légères modifications de nom pour les identifiants courts Co-authored-by: Paul Chavard <github@paul.chavard.net> Co-authored-by: Johan Girod <dev@johangirod.com> close #552
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import Engine from '../source/index'
|
|
import serializeEvaluation from '../source/serializeEvaluation'
|
|
import { expect } from 'chai'
|
|
|
|
describe('serializeEvaluation', () => {
|
|
it('should serialize a number', () => {
|
|
const engine = new Engine()
|
|
const expression = '2300'
|
|
const evaluation = engine.evaluate(expression)
|
|
|
|
expect(serializeEvaluation(evaluation)).to.eq(expression)
|
|
})
|
|
|
|
it('should serialize a boolean', () => {
|
|
const engine = new Engine()
|
|
const expression = 'oui'
|
|
const evaluation = engine.evaluate(expression)
|
|
|
|
expect(serializeEvaluation(evaluation)).to.eq(expression)
|
|
})
|
|
|
|
it('should serialize a number with unit', () => {
|
|
const engine = new Engine()
|
|
const expression = '457€/mois'
|
|
const evaluation = engine.evaluate(expression)
|
|
|
|
expect(serializeEvaluation(evaluation)).to.eq(expression)
|
|
})
|
|
|
|
it('should serialize a string', () => {
|
|
const engine = new Engine()
|
|
const expression = "'CDI'"
|
|
const evaluation = engine.evaluate(expression)
|
|
|
|
expect(serializeEvaluation(evaluation)).to.eq(expression)
|
|
})
|
|
|
|
it.skip('should serialize an object', () => {
|
|
const engine = new Engine()
|
|
const expression = '{ a: 45, b: {a: 15}}'
|
|
const evaluation = engine.evaluate(expression)
|
|
|
|
expect(serializeEvaluation(evaluation)).to.eq(expression)
|
|
})
|
|
})
|