Refactor for tests
This commit is contained in:
parent
201919a747
commit
24b2389abc
10
package.json
10
package.json
|
|
@ -26,7 +26,8 @@
|
||||||
"start": "node ./node_modules/.bin/gulp",
|
"start": "node ./node_modules/.bin/gulp",
|
||||||
"once": "node ./node_modules/.bin/gulp run-pipeline",
|
"once": "node ./node_modules/.bin/gulp run-pipeline",
|
||||||
"deploy": "npm run test && cp -r dist demo && git push origin `git subtree split --prefix demo develop`:gh-pages --force",
|
"deploy": "npm run test && cp -r dist demo && git push origin `git subtree split --prefix demo develop`:gh-pages --force",
|
||||||
"e2e-test": "npm run once && node ./node_modules/.bin/ava",
|
"test": "npm run once && node ./node_modules/.bin/ava",
|
||||||
|
"test:watch": "npm run once && node ./node_modules/.bin/ava --watch",
|
||||||
"format": "prettier {tasks,tests}/**/*.js gulpfile.js .eslintrc.js --write",
|
"format": "prettier {tasks,tests}/**/*.js gulpfile.js .eslintrc.js --write",
|
||||||
"lint": "eslint ./**/*.js gulpfile.js"
|
"lint": "eslint ./**/*.js gulpfile.js"
|
||||||
},
|
},
|
||||||
|
|
@ -73,8 +74,13 @@
|
||||||
],
|
],
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-push": "npm run e2e-test",
|
"pre-push": "npm run test",
|
||||||
"pre-commit": "npm run lint && ./node_modules/.bin/pretty-quick --staged --pattern ./**/*.js"
|
"pre-commit": "npm run lint && ./node_modules/.bin/pretty-quick --staged --pattern ./**/*.js"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"ava": {
|
||||||
|
"helpers": [
|
||||||
|
"**/util.js"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,12 @@ const outputWarningsForUnusedItems = (unusedItems, configs) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In a directory, checks for unused configs.
|
||||||
|
*
|
||||||
|
* @param { string } rootDir
|
||||||
|
* @param { Array } configs Array of configs.
|
||||||
|
*/
|
||||||
const checkForUnusedItemsInConfigs = (rootDir, configs) => {
|
const checkForUnusedItemsInConfigs = (rootDir, configs) => {
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
configs.map(async ({ dir, confItems }) => {
|
configs.map(async ({ dir, confItems }) => {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
const test = require('ava');
|
const test = require('ava');
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { readFileSync } = require('../util');
|
||||||
const readFileSync = path => fs.readFileSync(('../', path), 'utf8');
|
|
||||||
|
|
||||||
test('dark signature output', async t => {
|
test('dark signature output', async t => {
|
||||||
const expected = readFileSync('tests/sample/dark/signature-dark.html');
|
const expected = readFileSync('tests/sample/dark/signature-dark.html');
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"id": "dark",
|
||||||
|
"signature": "Best regards,",
|
||||||
|
"name": "The dark mail team",
|
||||||
|
"contactMain": "Call <a href='tel:004580100100'><span>(45) 80100100</span></a> or email us at",
|
||||||
|
"contactMail": "info@dark.dk",
|
||||||
|
"slogan": "LED Pylon. LED Wall. Digital Signage.",
|
||||||
|
"logoUrl": "/assets/dark.png",
|
||||||
|
"logoAlt": "dark logo",
|
||||||
|
"website": "http://dark.dk"
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,13 @@
|
||||||
const test = require('ava');
|
const test = require('ava');
|
||||||
|
const { checkForUnusedItemsInConfigs } = require('../../tasks/check-for-unused.js');
|
||||||
|
const { readFileSync } = require('../util');
|
||||||
|
|
||||||
test('noop', async t => { t.deepEqual('', ''); });
|
test('getting templates from filelist', async t => {
|
||||||
|
const configs = [
|
||||||
|
{ confItems: [readFileSync('tests/sample/configs/config-with-unused.json')], dir: 'dark' }
|
||||||
|
];
|
||||||
|
const expect = [[[[]]]];
|
||||||
|
const result = [await checkForUnusedItemsInConfigs('tests/sample', configs)];
|
||||||
|
|
||||||
|
t.deepEqual(result, expect);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
readFileSync: path => fs.readFileSync(('./', path), 'utf8')
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue