Facilitation des tests de mécanismes avec npm run test-meca

Ajout du nom des tests.
Nettoyage.
pull/37/head
mama 2017-08-16 13:56:14 +02:00
parent b7a81813c6
commit 5012d4f718
5 changed files with 12 additions and 25 deletions

View File

@ -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"
}
}

View File

@ -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

View File

@ -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
)
})
))
})
)
))
)
)

View File

@ -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%

View File

@ -5,6 +5,7 @@
format: kg
- nom: poids total
test: Somme
formule:
somme:
- farine