amend serverProcess test to update first

This commit is contained in:
Lachlan Kermode
2018-12-15 10:58:28 +00:00
parent 909b9fd21b
commit 64ca47ee8e
3 changed files with 17 additions and 17 deletions

View File

@@ -16,7 +16,7 @@ function checkStatus (res) {
/* SETUP: launch a development server with a wait time */
test.before.cb(t => {
console.log('launching server...')
console.log('SETUP: launching server and updating...')
serverProc = childProcess.spawn('yarn', ['dev'], {
cwd: '.',
stdio: 'ignore'
@@ -26,7 +26,21 @@ test.before.cb(t => {
serverExited = true
})
setTimeout(t.end, SERVER_LAUNCH_WAIT_TIME)
function pingUpdate () {
const expected = {
success: 'All sheets updated'
}
return fetch(`${SERVER_ROOT}/api/update`)
.then(checkStatus)
.then(res => res.json())
.then(json => {
t.deepEqual(json, expected)
t.end()
})
}
setTimeout(pingUpdate, SERVER_LAUNCH_WAIT_TIME)
})
/* CLEANUP: kill the server */
@@ -39,19 +53,6 @@ test('should launch', t => {
t.false(serverExited)
})
test('should update', t => {
const expected = {
success: 'All sheets updated'
}
return fetch(`${SERVER_ROOT}/api/update`)
.then(checkStatus)
.then(res => res.json())
.then(json => {
t.deepEqual(json, expected)
})
})
const passUrls = [
// /
'/api/',