mon-entreprise/source/components/Mecanisms.js

49 lines
1.0 KiB
JavaScript
Raw Normal View History

// Page listing the engine's currently implemented mecanisms and their tests
import React, { Component } from 'react'
import knownMecanims from 'Engine/known-mecanisms.yaml'
import R from 'ramda'
import './Mecanisms.css'
let directoryLoader = require.context('../../test/mécanismes/', true, /.yaml$/),
2017-11-30 10:05:25 +00:00
suites = R.fromPairs(
directoryLoader
.keys()
.map(key => [
key.replace(/\/|\.|(yaml)/g, '').replace(/-/g, ' '),
directoryLoader(key)
])
)
export default class Mecanisms extends Component {
render() {
return (
<ul id="mecanisms">
{R.toPairs(knownMecanims).map(([name, data]) => (
<li key={name}>
{name}
2017-11-30 10:05:25 +00:00
{suites[name] == null ? (
<p className="warning">Pas de tests !</p>
) : (
2017-11-30 10:05:25 +00:00
<Tests name={name} suites={suites} />
)}
</li>
))}
</ul>
)
}
}
2017-11-30 10:05:25 +00:00
class Tests extends Component {
render() {
let { suites, name } = this.props,
suite = suites[name],
tests = suite.filter(R.has('test'))
return (
<p>
{tests.length} {tests.length == 1 ? 'test' : 'tests'}
</p>
)
}
}