Migrated to Fusebox

This commit is contained in:
NGPixel
2017-03-26 22:07:40 -04:00
parent d4e0b74975
commit 5189ec3835
21 changed files with 59663 additions and 217 deletions

View File

@@ -1,3 +0,0 @@
'use strict'
// TODO

77
test/lint.js Normal file
View File

@@ -0,0 +1,77 @@
'use strict'
const fs = require('fs-extra')
const colors = require('colors')
expect.extend({
/**
* Expect ESLint results to have no errors
* @param {*} received ESLint results
* @param {*} argument Arguments
* @returns {object} Matcher result
*/
toESLint (received, argument) {
if (received && received.errorCount > 0) {
let errorMsgBuf = []
for (let i = 0; i < received.results.length; i++) {
const result = received.results[i]
if (result.errorCount <= 0) {
continue
}
for (let x = 0; x < result.messages.length; x++) {
const m = result.messages[x]
errorMsgBuf.push(colors.grey(`└── ${result.filePath}\t${m.line}:${m.column}\t${m.message}`))
}
}
if (errorMsgBuf.length > 0) {
return {
message: () => (errorMsgBuf.join(`\n`)),
pass: false
}
}
}
return {
pass: true
}
},
/**
* Expect PugLint results to have no errors
* @param {*} received PugLint results
* @param {*} argument Arguments
* @returns {object} Matcher result
*/
toPugLint (received, argument) {
if (received && received.length > 0) {
let errorMsgBuf = []
for (let i = 0; i < received.length; i++) {
errorMsgBuf.push(colors.grey(`└── ${received[i].message}`))
}
return {
message: () => (errorMsgBuf.join(`\n`)),
pass: false
}
}
return {
pass: true
}
}
})
describe('Code Linting', () => {
it('should pass ESLint validation', () => {
const CLIEngine = require('eslint').CLIEngine
const cli = new CLIEngine()
let report = cli.executeOnFiles(['**/*.js'])
expect(report).toESLint()
})
it('should pass PugLint validation', () => {
const PugLint = require('pug-lint')
const lint = new PugLint()
const pugConfig = fs.readJsonSync('.pug-lintrc.json')
lint.configure(pugConfig)
let report = lint.checkPath('./views')
expect(report).toPugLint()
})
})

39
test/security.js Normal file
View File

@@ -0,0 +1,39 @@
'use strict'
const colors = require('colors')
expect.extend({
/**
* Expect Snyk results to have no errors
* @param {*} received Snyk results
* @param {*} argument Arguments
* @returns {object} Matcher result
*/
toPassSnyk (received, argument) {
if (received && received.ok === false) {
let errorMsgBuf = []
for (let i = 0; i < received.vulnerabilities.length; i++) {
const result = received.vulnerabilities[i]
let vulnPath = result.from.slice(1).join(' > ')
errorMsgBuf.push(colors.red(`└──[${result.severity}] ${result.packageName}\t${result.title}`))
errorMsgBuf.push(colors.grey(`\t${vulnPath}`))
}
return {
message: () => (errorMsgBuf.join(`\n`)),
pass: false
}
}
return {
pass: true
}
}
})
describe('Security', () => {
it('should pass Snyk test', () => {
const snyk = require('snyk').test
return snyk('./').then(report => {
expect(report).toPassSnyk()
})
}, 20000)
})