lint: src/node/hooks/express/tests.js
parent
6df3eadecd
commit
2dec36bfd7
|
@ -1,9 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const npm = require('npm');
|
||||
const fs = require('fs');
|
||||
const util = require('util');
|
||||
|
||||
exports.expressCreateServer = function (hook_name, args, cb) {
|
||||
exports.expressCreateServer = (hookName, args, cb) => {
|
||||
args.app.get('/tests/frontend/specs_list.js', async (req, res) => {
|
||||
const [coreTests, pluginTests] = await Promise.all([
|
||||
exports.getCoreTests(),
|
||||
|
@ -24,9 +26,9 @@ exports.expressCreateServer = function (hook_name, args, cb) {
|
|||
// path.join seems to normalize by default, but we'll just be explicit
|
||||
const rootTestFolder = path.normalize(path.join(npm.root, '../tests/frontend/'));
|
||||
|
||||
const url2FilePath = function (url) {
|
||||
const url2FilePath = (url) => {
|
||||
let subPath = url.substr('/tests/frontend'.length);
|
||||
if (subPath == '') {
|
||||
if (subPath === '') {
|
||||
subPath = 'index.html';
|
||||
}
|
||||
subPath = subPath.split('?')[0];
|
||||
|
@ -49,8 +51,9 @@ exports.expressCreateServer = function (hook_name, args, cb) {
|
|||
|
||||
content = `describe(${JSON.stringify(specFileName)}, function(){ ${content} });`;
|
||||
|
||||
if(!specFilePath.endsWith('index.html')) res.setHeader('content-type', 'application/javascript');
|
||||
|
||||
if (!specFilePath.endsWith('index.html')) {
|
||||
res.setHeader('content-type', 'application/javascript');
|
||||
}
|
||||
res.send(content);
|
||||
});
|
||||
});
|
||||
|
@ -69,7 +72,7 @@ exports.expressCreateServer = function (hook_name, args, cb) {
|
|||
|
||||
const readdir = util.promisify(fs.readdir);
|
||||
|
||||
exports.getPluginTests = async function (callback) {
|
||||
exports.getPluginTests = async (callback) => {
|
||||
const moduleDir = 'node_modules/';
|
||||
const specPath = '/static/tests/frontend/specs/';
|
||||
const staticDir = '/static/plugins/';
|
||||
|
@ -88,7 +91,4 @@ exports.getPluginTests = async function (callback) {
|
|||
return Promise.all(promises).then(() => pluginSpecs);
|
||||
};
|
||||
|
||||
exports.getCoreTests = function () {
|
||||
// get the core test specs
|
||||
return readdir('tests/frontend/specs');
|
||||
};
|
||||
exports.getCoreTests = () => readdir('tests/frontend/specs');
|
||||
|
|
Loading…
Reference in New Issue