Add linting and cleaned up obvious suggestions

This commit is contained in:
Phil Denoncourt
2019-01-18 07:56:53 -05:00
parent ebf32199ce
commit 0002fe0df8
46 changed files with 1161 additions and 601 deletions

View File

@@ -1,68 +1,65 @@
var assert = require('assert');
var child_process = require('child_process')
var http = require('http');
import test from 'ava'
var childProcess = require('childProcess')
var http = require('http')
const SERVER_LAUNCH_WAIT_TIME = 5 * 1000;
const SERVER_LAUNCH_WAIT_TIME = 5 * 1000
var server_proc = null;
var server_exited = false;
var serverProc = null
var serverExited = false
test.before.cb(t => {
console.log("launching server...")
server_proc = child_process.spawn('yarn', ['dev'], {
console.log('launching server...')
serverProc = childProcess.spawn('yarn', ['dev'], {
cwd: '.',
stdio: 'ignore'
});
})
server_proc.on('exit', function(code, signal) {
server_exited = true;
});
serverProc.on('exit', function (code, signal) {
serverExited = true
})
setTimeout(t.end, SERVER_LAUNCH_WAIT_TIME)
});
})
test.after(function() {
console.log("killing server...")
server_proc.kill('SIGKILL');
});
test.after(function () {
console.log('killing server...')
serverProc.kill('SIGKILL')
})
test('should launch', t => {
t.false(server_exited);
});
t.false(serverExited)
})
var urls = [
'/',
'js/index.bundle.js'
];
]
urls.forEach(function(url) {
urls.forEach(function (url) {
test.cb('should respond to request for "' + url + '"', t => {
http.get({
hostname: 'localhost',
port: 8080,
path: '/',
agent: false
}, function(res) {
var result_data = '';
}, function (res) {
var resultData = ''
if(res.statusCode != 200) {
t.fail('Server response was not 200.');
if (res.statusCode !== 200) {
t.fail('Server response was not 200.')
} else {
res.on('data', function(data) { result_data += data });
res.on('data', function (data) { resultData += data })
res.on('end', function() {
if (result_data.length > 0) {
t.pass();
res.on('end', function () {
if (resultData.length > 0) {
t.pass()
} else {
t.fail("Server returned no data.");
t.fail('Server returned no data.')
}
});
})
}
t.end();
t.end()
})
});
});
})
})