✅ Amélioration du test des mécanismes
parent
914327398c
commit
9390baa53b
|
@ -23,8 +23,9 @@ export let getIframeOption = (optionName: string) => {
|
|||
)
|
||||
}
|
||||
|
||||
// By luck this works as expected for both null and undefined, * but with different branches failing :O *
|
||||
export let isFloat = (n: number) => Number(n) === n && n % 1 !== 0
|
||||
export function isNumeric(val: number) {
|
||||
return Number(parseFloat(val)) === val
|
||||
}
|
||||
|
||||
export function debounce<ArgType: any>(
|
||||
timeout: number,
|
||||
|
|
|
@ -10,7 +10,7 @@ import { analyse, parseAll } from '../source/engine/traverse'
|
|||
import { collectMissingVariables } from '../source/engine/generateQuestions'
|
||||
import testSuites from './load-mecanism-tests'
|
||||
import * as R from 'ramda'
|
||||
import { isFloat } from '../source/utils'
|
||||
import { isNumeric } from '../source/utils'
|
||||
|
||||
describe('Mécanismes', () =>
|
||||
testSuites.map(suite =>
|
||||
|
@ -45,8 +45,7 @@ describe('Mécanismes', () =>
|
|||
missing = collectMissingVariables(analysis.targets),
|
||||
target = analysis.targets[0]
|
||||
|
||||
// console.log('JSON.stringify(analysis', JSON.stringify(analysis))
|
||||
if (isFloat(valeur)) {
|
||||
if (isNumeric(valeur)) {
|
||||
expect(target.nodeValue).to.be.closeTo(valeur, 0.001)
|
||||
} else if (valeur !== undefined) {
|
||||
expect(target).to.have.property('nodeValue', valeur)
|
||||
|
|
Loading…
Reference in New Issue