diff --git a/package.json b/package.json index b9808ffc6..09a7157a4 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "compile": "NODE_ENV='production' webpack --config source/webpack.config.js", "surge": "npm run compile && surge --domain scientific-wish.surge.sh -p ./ && rm -rf dist/", "test": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\"", - "test-watch": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\" --watch" + "test-watch": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\" --watch", + "test-meca": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js test/mecanisms.test.js" } } diff --git a/test/load-mecanism-tests.js b/test/load-mecanism-tests.js index 760ac1bf7..d3c12ef59 100644 --- a/test/load-mecanism-tests.js +++ b/test/load-mecanism-tests.js @@ -1,23 +1,8 @@ import R from 'ramda' -// This array can't be generated, as the arguments to require.context must be literals :-| -let directoryLoaders = - [ - - ] - -// require.context returns an object which -// a) is a function behaving like 'requires', taking a filename and returning a module and -// b) has additional properties, some function-valued; keys() returns the files matched -// A "module" is simply the contents of a file according to a Webpack loader; this can be JS, JSON, etc. -// Thus, this weird loadAll returns an array, each item of which is the contents of each file in a directory -let loadAll = directoryLoaderFunction => - directoryLoaderFunction.keys().map(directoryLoaderFunction) - let directoryLoaderFunction = require.context('./mécanismes', true, /.yaml$/) -let items = - loadAll(directoryLoaderFunction) -console.log('items', items) +let items = directoryLoaderFunction.keys().map(directoryLoaderFunction) + export default items diff --git a/test/mecanisms.test.js b/test/mecanisms.test.js index 413a0906b..1131b70b7 100644 --- a/test/mecanisms.test.js +++ b/test/mecanisms.test.js @@ -10,11 +10,11 @@ import {analyseSituation} from '../source/engine/traverse' import testBatteries from './load-mecanism-tests' -describe('mécanismes', () => +describe('Mécanismes', () => testBatteries.map( battery => - describe('mecanisme' + Math.random(), function() { - battery.map(({exemples, nom}) => - exemples && exemples.map(({nom: testTexte, situation, 'valeur attendue': valeur}) => + battery.map(({exemples, nom, test}) => + exemples && describe(test || 'Nom de test (propriété "test") manquant dans la variable contenant ces "exemples"', () => + exemples.map(({nom: testTexte, situation, 'valeur attendue': valeur}) => it(testTexte + '', () => { let rules = battery.map(enrichRule), state = situation || {}, @@ -27,7 +27,7 @@ describe('mécanismes', () => valeur ) }) - )) - }) + ) + )) ) ) diff --git a/test/mécanismes/aiguillage-numérique.yaml b/test/mécanismes/aiguillage-numérique.yaml index 28680df9d..c996f5f98 100644 --- a/test/mécanismes/aiguillage-numérique.yaml +++ b/test/mécanismes/aiguillage-numérique.yaml @@ -37,7 +37,7 @@ format: € - nom: retenue sur dépot de garantie 2 - test: Aiguillages numériques imbriqués + test: Imbrication d'aiguillages numériques formule: aiguillage numérique: dégradation mineure: 5% diff --git a/test/mécanismes/somme.yaml b/test/mécanismes/somme.yaml index 9c6a8c399..c3e3f2936 100644 --- a/test/mécanismes/somme.yaml +++ b/test/mécanismes/somme.yaml @@ -5,6 +5,7 @@ format: kg - nom: poids total + test: Somme formule: somme: - farine