✅ Tentative pour tester sans Webpack
parent
1e15fffecf
commit
32edfa57a8
|
@ -34,7 +34,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^7.1.1",
|
||||
"babel-cli": "^6.23.0",
|
||||
"babel-cli": "^6.24.1",
|
||||
"babel-core": "^6.24.1",
|
||||
"babel-eslint": "^7.2.3",
|
||||
"babel-loader": "^7.0.0",
|
||||
|
@ -46,6 +46,7 @@
|
|||
"babel-preset-env": "^1.4.0",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"chai": "^4.0.2",
|
||||
"chokidar": "^1.7.0",
|
||||
"core-js": "^2.4.1",
|
||||
"css-loader": "^0.28.1",
|
||||
"eslint": "^3.19.0",
|
||||
|
@ -75,6 +76,7 @@
|
|||
"start": "node source/server.js",
|
||||
"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.config.js --require source-map-support/register --require __tests__/helpers/browser.js \"__tests__/**/*.test.js\""
|
||||
"test": "mocha-webpack --webpack-config source/webpack.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\"",
|
||||
"test-fast": "babel-node --presets babel-preset-flow,babel-preset-env --plugins transform-class-properties test/helpers/runner.js"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import { withRouter } from 'react-router'
|
|||
import R from 'ramda'
|
||||
import './Results.css'
|
||||
import {capitalise0} from '../utils'
|
||||
import {computeRuleValue} from 'Engine/traverse'
|
||||
import {encodeRuleName, getObjectives} from 'Engine/rules'
|
||||
import {computeRuleValue} from '../engine/traverse'
|
||||
import {encodeRuleName, getObjectives} from '../engine/rules'
|
||||
|
||||
let fmt = new Intl.NumberFormat('fr-FR').format
|
||||
let humanFigure = decimalDigits => value => fmt(value.toFixed(decimalDigits))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import React, {Component} from 'react'
|
||||
import HoverDecorator from 'Components/HoverDecorator'
|
||||
import HoverDecorator from './HoverDecorator'
|
||||
import 'whatwg-fetch'
|
||||
import {connect} from 'react-redux'
|
||||
import './Satisfaction.css'
|
||||
|
|
|
@ -5,13 +5,13 @@ import {START_CONVERSATION} from '../actions'
|
|||
import R from 'ramda'
|
||||
import {Redirect, Link, withRouter} from 'react-router-dom'
|
||||
import Aide from './Aide'
|
||||
import {createMarkdownDiv} from 'Engine/marked'
|
||||
import {rules, findRuleByName, decodeRuleName} from 'Engine/rules'
|
||||
import 'Components/conversation/conversation.css'
|
||||
import 'Components/Simulateur.css'
|
||||
import {createMarkdownDiv} from '../engine/marked'
|
||||
import {rules, findRuleByName, decodeRuleName} from '../engine/rules'
|
||||
import './conversation/conversation.css'
|
||||
import './Simulateur.css'
|
||||
import classNames from 'classnames'
|
||||
import {capitalise0} from '../utils'
|
||||
import Satisfaction from 'Components/Satisfaction'
|
||||
import Satisfaction from './Satisfaction'
|
||||
import Helmet from 'react-helmet'
|
||||
|
||||
let situationSelector = formValueSelector('conversation')
|
||||
|
|
|
@ -2,8 +2,8 @@ import React from 'react'
|
|||
import classNames from 'classnames'
|
||||
import R from 'ramda'
|
||||
import {AttachDictionary} from '../AttachDictionary'
|
||||
import knownMecanisms from 'Engine/known-mecanisms.yaml'
|
||||
import marked from 'Engine/marked'
|
||||
import knownMecanisms from '../../engine/known-mecanisms.yaml'
|
||||
import marked from '../../engine/marked'
|
||||
|
||||
@AttachDictionary(knownMecanisms)
|
||||
export default class Algorithm extends React.Component {
|
||||
|
|
|
@ -5,8 +5,8 @@ import {
|
|||
rules,
|
||||
decodeRuleName,
|
||||
disambiguateRuleReference
|
||||
} from "Engine/rules.js"
|
||||
import { analyseSituation } from "Engine/traverse"
|
||||
} from "../../engine/rules.js"
|
||||
import { analyseSituation } from "../../engine/traverse"
|
||||
import "./Examples.css"
|
||||
|
||||
export default class Examples extends Component {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React from 'react'
|
||||
import R from 'ramda'
|
||||
import references from 'Règles/ressources/références/références.yaml'
|
||||
import references from '../../../../règles/ressources/références/références.yaml'
|
||||
import './References.css'
|
||||
|
||||
export default ({refs}) => (
|
||||
|
@ -18,7 +18,7 @@ export default ({refs}) => (
|
|||
<span className="url">
|
||||
{domain}
|
||||
{refData.image &&
|
||||
<img src={require('Règles/ressources/références/' + refData.image)}/> }
|
||||
<img src={require('../../../../règles/ressources/références/' + refData.image)}/> }
|
||||
</span>
|
||||
</span>
|
||||
<a href={link} target="_blank">
|
||||
|
|
|
@ -4,11 +4,11 @@ import {connect} from 'react-redux'
|
|||
import {formValueSelector} from 'redux-form'
|
||||
import R from 'ramda'
|
||||
import './Rule.css'
|
||||
import {rules, decodeRuleName} from 'Engine/rules.js'
|
||||
import mockSituation from 'Engine/mockSituation.yaml'
|
||||
import {analyseSituation} from 'Engine/traverse'
|
||||
import {rules, decodeRuleName} from '../../engine/rules.js'
|
||||
import mockSituation from '../../engine/mockSituation.yaml'
|
||||
import {analyseSituation} from '../../engine/traverse'
|
||||
import {START_CONVERSATION} from '../../actions'
|
||||
import possiblesDestinataires from 'Règles/ressources/destinataires/destinataires.yaml'
|
||||
import possiblesDestinataires from '../../../règles/ressources/destinataires/destinataires.yaml'
|
||||
import {capitalise0} from '../../utils'
|
||||
import References from './References'
|
||||
import Algorithm from './Algorithm'
|
||||
|
@ -89,7 +89,7 @@ export default class Rule extends Component {
|
|||
: <div>
|
||||
<a href={destinataireData.lien} target="_blank">
|
||||
{destinataireData.image &&
|
||||
<img src={require('Règles/ressources/destinataires/' + destinataireData.image)} /> }
|
||||
<img src={require('../../../../règles/ressources/destinataires/' + destinataireData.image)} /> }
|
||||
{!destinataireData.image &&
|
||||
<div id="calligraphy">{destinataire}</div>
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ import React, { Component } from 'react'
|
|||
import './Layout.css'
|
||||
import './reset.css'
|
||||
import {Link, Route, BrowserRouter as Router, Switch} from 'react-router-dom'
|
||||
import HomeEmbauche from 'Components/HomeEmbauche'
|
||||
import HomeSyso from 'Components/HomeSyso'
|
||||
import Rule from 'Components/rule/Rule'
|
||||
import Route404 from 'Components/Route404'
|
||||
import Contact from 'Components/Contact'
|
||||
import Simulateur from 'Components/Simulateur'
|
||||
import Results from 'Components/Results'
|
||||
import HomeEmbauche from '../components/HomeEmbauche'
|
||||
import HomeSyso from '../components/HomeSyso'
|
||||
import Rule from '../components/rule/Rule'
|
||||
import Route404 from '../components/Route404'
|
||||
import Contact from '../components/Contact'
|
||||
import Simulateur from '../components/Simulateur'
|
||||
import Results from '../components/Results'
|
||||
|
||||
|
||||
export default class Layout extends Component {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import React from 'react'
|
||||
import Explicable from 'Components/conversation/Explicable'
|
||||
import Explicable from '../components/conversation/Explicable'
|
||||
import R from 'ramda'
|
||||
import Question from 'Components/conversation/Question'
|
||||
import Input from 'Components/conversation/Input'
|
||||
import formValueTypes from 'Components/conversation/formValueTypes'
|
||||
import Question from '../components/conversation/Question'
|
||||
import Input from '../components/conversation/Input'
|
||||
import formValueTypes from '../components/conversation/formValueTypes'
|
||||
import {analyseSituation} from './traverse'
|
||||
import {formValueSelector} from 'redux-form'
|
||||
import { STEP_ACTION, START_CONVERSATION} from '../actions'
|
||||
|
|
|
@ -1,7 +1,45 @@
|
|||
import R from 'ramda'
|
||||
|
||||
// This is a mock of webpack's require.context, for testing purposes
|
||||
if (typeof require.context === 'undefined') {
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
require.context = (base = '.', scanSubDirectories = false, regularExpression = /\.js$/) => {
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
const files = {};
|
||||
|
||||
function readDirectory(directory) {
|
||||
fs.readdirSync(directory).forEach((file) => {
|
||||
const fullPath = path.resolve(directory, file);
|
||||
|
||||
if (fs.statSync(fullPath).isDirectory()) {
|
||||
if (scanSubDirectories) readDirectory(fullPath);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!regularExpression.test(fullPath)) return;
|
||||
|
||||
files[fullPath] = true;
|
||||
});
|
||||
}
|
||||
|
||||
readDirectory(path.resolve(__dirname, base));
|
||||
|
||||
function Module(file) {
|
||||
return yaml.safeLoad(fs.readFileSync(file, 'utf8'));
|
||||
}
|
||||
|
||||
Module.keys = () => Object.keys(files);
|
||||
|
||||
return Module;
|
||||
};
|
||||
}
|
||||
|
||||
// This array can't be generated, as the arguments to require.context must be literals :-|
|
||||
let directoryLoaders =
|
||||
let directoryLoaders =
|
||||
[
|
||||
require.context('../../règles/rémunération-travail/cdd',
|
||||
true, /([A-Za-z\u00C0-\u017F]|\.|-|_)+.yaml$/),
|
||||
|
|
|
@ -153,12 +153,8 @@ export let collectMissingVariables = (groupMethod='groupByMissingVariable') => a
|
|||
let isVariant = R.path(['formule', 'une possibilité'])
|
||||
|
||||
export let findVariantsAndRecords =
|
||||
(allRules, memo, dottedName, childDottedName) => {
|
||||
console.log("memo",memo)
|
||||
console.log("dottedName",dottedName)
|
||||
console.log("childDottedName",childDottedName)
|
||||
let {variantGroups, recordGroups} = memo,
|
||||
child = findRuleByDottedName(allRules, dottedName),
|
||||
(allRules, {variantGroups, recordGroups}, dottedName, childDottedName) => {
|
||||
let child = findRuleByDottedName(allRules, dottedName),
|
||||
parentDottedName = parentName(dottedName),
|
||||
parent = findRuleByDottedName(allRules, parentDottedName)
|
||||
if (isVariant(parent)) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react'
|
|||
import R from 'ramda'
|
||||
import classNames from 'classnames'
|
||||
import {Link} from 'react-router-dom'
|
||||
import {encodeRuleName} from 'Engine/rules'
|
||||
import {encodeRuleName} from './rules'
|
||||
|
||||
let treatValue = data =>
|
||||
data == null
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
import Mocha from 'mocha';
|
||||
import chokidar from 'chokidar';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const noop = () => {}
|
||||
|
||||
const loadYaml = (module, filename) => {
|
||||
const yaml = require('js-yaml');
|
||||
module.exports = yaml.safeLoad(fs.readFileSync(filename, 'utf8'));
|
||||
}
|
||||
|
||||
const loadNearley = (module, filename) => {
|
||||
var nearley = require('nearley/lib/nearley.js');
|
||||
var compile = require('nearley/lib/compile.js');
|
||||
var generate = require('nearley/lib/generate.js');
|
||||
var grammar = require('nearley/lib/nearley-language-bootstrapped.js');
|
||||
|
||||
var parser = new nearley.Parser(grammar.ParserRules, grammar.ParserStart);
|
||||
parser.feed(fs.readFileSync(filename, 'utf8'));
|
||||
var compilation = compile(parser.results[0], {});
|
||||
var content = generate(compilation, 'Grammar');
|
||||
|
||||
module._compile(content,filename)
|
||||
}
|
||||
|
||||
require.extensions['.yaml'] = loadYaml
|
||||
require.extensions['.ne'] = loadNearley
|
||||
require.extensions['.css'] = noop
|
||||
|
||||
let fileList = [];
|
||||
function runSuite() {
|
||||
Object.keys( require.cache ).forEach( key => delete require.cache[ key ] );
|
||||
const mocha = new Mocha( { reporter: 'dot' } );
|
||||
fileList.forEach( filepath => mocha.addFile( filepath ) );
|
||||
mocha.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Chokidar watches all the files for any kind of change and calls the run function
|
||||
* from above. Read more: https://github.com/paulmillr/chokidar
|
||||
* @param {string} a glob of files to watch
|
||||
* @param {object} settings
|
||||
*/
|
||||
chokidar.watch( 'test/**/*.test.js', { persistent: true } )
|
||||
.on( 'add', path => fileList.push( path ) )
|
||||
.on( 'change', path => runSuite() )
|
||||
.on( 'ready', () => runSuite() );
|
||||
|
||||
chokidar.watch( 'source/**/*.js', { persistent: true } )
|
||||
.on( 'change', path => runSuite() )
|
|
@ -0,0 +1,2 @@
|
|||
--compilers js:babel-register
|
||||
test/**/*.test.js
|
Loading…
Reference in New Issue