Skip to content

Commit

Permalink
ajout mocha-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Perrin committed Mar 16, 2020
1 parent c7d9e8b commit d9663f6
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Expand Up @@ -4,7 +4,7 @@
"prefer-const": "off",
"max-len": [
"warn",
160
200
],
"quotes": [
"warn",
Expand Down
10 changes: 9 additions & 1 deletion backend/.eslintrc.json
@@ -1,6 +1,7 @@
{
"extends": [
"../.eslintrc.json"
"../.eslintrc.json",
"plugin:mocha/recommended"
],
"env": {
"node": true,
Expand All @@ -9,5 +10,12 @@
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"mocha/no-mocha-arrows":"off",
"mocha/no-setup-in-describe":"off",
"mocha/no-exclusive-tests":"error",
"mocha/no-top-level-hooks":"off",
"mocha/no-hooks-for-single-case":"off"
}
}
27 changes: 27 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Expand Up @@ -79,6 +79,7 @@
},
"devDependencies": {
"eslint": "6.8.0",
"eslint-plugin-mocha": "6.3.0",
"mocha": "6.2.2",
"nodemon": "2.0.2",
"nyc": "14.1.1",
Expand Down
2 changes: 1 addition & 1 deletion backend/src/http/site/static/js/faq.js
Expand Up @@ -13,4 +13,4 @@ $(document).ready(function() {
elem.next().toggle();
$('.question.open').not(elem).removeClass('open').addClass('closed').next().hide();
});
});
});
@@ -1,5 +1,3 @@
/* eslint-disable no-var */
/* global window, document, navigator, XMLHttpRequest */
(function() {

window.anotea = window.anotea || {};
Expand Down
1 change: 1 addition & 0 deletions backend/src/http/utils/validators-utils.js
Expand Up @@ -4,6 +4,7 @@ const arrayAsString = () => {
return Joi.extend(joi => ({
base: joi.array(),
name: 'arrayAsString',
// eslint-disable-next-line no-unused-vars
coerce: (value, state, options) => {
return ((value && value.split) ? value.split(',') : value);
},
Expand Down
2 changes: 1 addition & 1 deletion backend/src/jobs/data/dataset/index.js
Expand Up @@ -78,7 +78,7 @@ execute(async ({ db, logger, workflow, regions, passwords }) => {
logins: [
{ profile: 'moderateur', login: 'moderateur', password },
{ profile: 'financeur', login: 'financeur', password },
{ profile: 'organisme', login: '22222222222222', password, },
{ profile: 'organisme', login: '22222222222222', password },
]
},
},
Expand Down
6 changes: 3 additions & 3 deletions backend/src/jobs/import/rome/importer.js
@@ -1,4 +1,4 @@
module.exports = function(db, logger, configuration) {
module.exports = function(db, logger) {

const fs = require('fs');
const moment = require('moment');
Expand All @@ -9,13 +9,13 @@ module.exports = function(db, logger, configuration) {
logger.info('ROME <-> FORMACODE mapping import - launch');

let promises = [];
return new Promise((resolve, reject) => {
return new Promise(resolve => {
let launchTime = new Date().getTime();
let parser = parse({ delimiter: ',', quote: '"' });
let input = fs.createReadStream(file, { encoding: 'utf-8' });
let count = 0;
let transformer = transform(async (record, callback) => {
let promise = new Promise(async (resolve, reject) => {
let promise = new Promise(async resolve => {
let formacodes = record[2].split('$').map(item => {
let formacodeArr = item.split(' ');
let formacode = formacodeArr.pop();
Expand Down
Expand Up @@ -202,7 +202,9 @@ describe(__filename, withServer(({ startServer, insertIntoDatabase, logAsOrganis
let response = await request(app)
.put(`/api/backoffice/avis/${avis._id}/addReponse`)
.set('authorization', `Bearer ${token}`)
.send({ text: 'Accusantium molestiae quasi enim facilis. Non deserunt autem ut sit est. Earum laudantium est amet soluta sed. Inventore eos nemo sunt sapiente atque ea repudiandae nam. Nihil nihil et consequatur nemo aut deserunt pariatur dolores. Accusantium molestiae quasi enim facilis. Accusantium molestiae quasi enim facilis.' });
.send({ text: 'Accusantium molestiae quasi enim facilis. Non deserunt autem ut sit est. Earum laudantium est amet soluta sed. ' +
'Inventore eos nemo sunt sapiente atque ea repudiandae nam. Nihil nihil et consequatur nemo aut deserunt pariatur dolores. ' +
'Accusantium molestiae quasi enim facilis. Accusantium molestiae quasi enim facilis.' });

assert.strictEqual(response.statusCode, 400);
assert.deepStrictEqual(response.body, {
Expand All @@ -218,7 +220,9 @@ describe(__filename, withServer(({ startServer, insertIntoDatabase, logAsOrganis
'type': 'string.max',
'context': {
'limit': 300,
'value': 'Accusantium molestiae quasi enim facilis. Non deserunt autem ut sit est. Earum laudantium est amet soluta sed. Inventore eos nemo sunt sapiente atque ea repudiandae nam. Nihil nihil et consequatur nemo aut deserunt pariatur dolores. Accusantium molestiae quasi enim facilis. Accusantium molestiae quasi enim facilis.',
'value': 'Accusantium molestiae quasi enim facilis. Non deserunt autem ut sit est. Earum laudantium est amet soluta sed. ' +
'Inventore eos nemo sunt sapiente atque ea repudiandae nam. Nihil nihil et consequatur nemo aut deserunt pariatur dolores. ' +
'Accusantium molestiae quasi enim facilis. Accusantium molestiae quasi enim facilis.',
'key': 'text',
'label': 'text'
}
Expand Down
33 changes: 0 additions & 33 deletions backend/test/integration/http/api/v1/avis-routes-test.js
Expand Up @@ -598,39 +598,6 @@ describe(__filename, withServer(({ startServer, insertIntoDatabase }) => {
});
});

it.skip('should return avis with partial intitulé and same siret/code_postal', async () => {

let app = await startServer();
let intitule = 'fullstack';
let siret = '12345678901234';
let codePostal = '75000';
let oid = new ObjectID();

await insertIntoDatabase('avis', newAvis({
_id: oid,
formation: {
intitule: 'Développeur fullstack',
action: {
lieu_de_formation: {
code_postal: codePostal,
},
organisme_formateur: {
siret,
},
},
},
}));

let response = await request(app).get(`/api/v1/organisme_formateurs/${siret}/lieu_de_formations/${codePostal}/formations/${intitule}/avis`);

assert.strictEqual(response.statusCode, 200);
let avis = response.body.avis.filter(a => a.id === oid.toString());
assert.strictEqual(avis.length, 1);
assert.deepStrictEqual(avis[0].formation.intitule, 'Développeur fullstack');
assert.deepStrictEqual(avis[0].formation.action.lieu_de_formation.code_postal, codePostal);
assert.deepStrictEqual(avis[0].formation.action.organisme_formateur.siret, siret);
});

it('can search avis and ignoring those archived', async () => {

let app = await startServer();
Expand Down
Expand Up @@ -475,7 +475,7 @@ describe(__filename, withServer(({ startServer, insertIntoDatabase }) => {
});
});

it('can return avis avec commentaires', async () => {
it('can return avis sans commentaires', async () => {

let app = await startServer();
let oid = new ObjectID();
Expand Down
Expand Up @@ -85,7 +85,7 @@ describe(__filename, withMongoDB(({ getTestDatabase, importIntercarif }) => {
});


it('should reject invalid csv file', async () => {
it('should reject invalid Kairos csv file', async () => {

let db = await getTestDatabase();
let invalidFile = path.join(__dirname, '../../../../helpers/data', 'kairos-organismes-invalid.csv');
Expand Down

0 comments on commit d9663f6

Please sign in to comment.