From a6d77851b3233afb5d0eaec8dbc651fcca561245 Mon Sep 17 00:00:00 2001 From: Taylor Schley Date: Fri, 20 Aug 2021 10:16:32 -0500 Subject: [PATCH] test: random fixes --- app/controllers/api/v1/jobs.js | 1 - test/api/v1/jobs/get.js | 2 +- test/api/v1/stop.js | 5 ++--- test/config/utilities.js | 7 +------ test/jobs/basic.js | 1 + test/jobs/long.js | 1 + 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/controllers/api/v1/jobs.js b/app/controllers/api/v1/jobs.js index 4ca3fe2..35f000c 100644 --- a/app/controllers/api/v1/jobs.js +++ b/app/controllers/api/v1/jobs.js @@ -27,7 +27,6 @@ async function add(ctx) { if (body.copy) { if (!_.isArray(body.jobs)) body.jobs = [body.jobs]; - console.log(body); const newJobs = []; diff --git a/test/api/v1/jobs/get.js b/test/api/v1/jobs/get.js index 91b11ef..e6eb1b5 100644 --- a/test/api/v1/jobs/get.js +++ b/test/api/v1/jobs/get.js @@ -39,7 +39,7 @@ test.before(async (t) => { test('successfully', async (t) => { const { api, bree } = t.context; - await delay(200); + await delay(300); const res = await api.get(rootUrl); diff --git a/test/api/v1/stop.js b/test/api/v1/stop.js index d026de1..f692b05 100644 --- a/test/api/v1/stop.js +++ b/test/api/v1/stop.js @@ -34,6 +34,8 @@ test.before(async (t) => { t.context.api = t.context.api.auth(t.context.token, { type: 'bearer' }); t.context.bree.start(); + + await delay(200); }); test.serial('successfully stop named job', async (t) => { @@ -45,15 +47,12 @@ test.serial('successfully stop named job', async (t) => { t.is(res.status, 200); - await delay(200); - t.falsy(bree.workers.active); }); test.serial('successfully stop all jobs', async (t) => { const { bree, api } = t.context; - t.not(Object.values(bree.workers).length, 0); t.not(Object.values(bree.timeouts).length, 0); t.not(Object.values(bree.intervals).length, 0); diff --git a/test/config/utilities.js b/test/config/utilities.js index ec4684e..6906c2e 100644 --- a/test/config/utilities.js +++ b/test/config/utilities.js @@ -1,12 +1,7 @@ const test = require('ava'); -const { json, emoji } = require('../../config/utilities'); +const { json } = require('../../config/utilities'); test('returns JSON with 2 spaces', (t) => { t.snapshot(json({ ok: 'hey' })); }); - -test('returns valid emoji or empty string', (t) => { - t.is(emoji('cat'), '🐱'); - t.is(emoji('invalid_emoji'), ''); -}); diff --git a/test/jobs/basic.js b/test/jobs/basic.js index c1cacac..9d31489 100644 --- a/test/jobs/basic.js +++ b/test/jobs/basic.js @@ -2,6 +2,7 @@ const { parentPort } = require('worker_threads'); setTimeout(() => { console.log('hello'); + process.exit(0); }, 100); if (parentPort) { diff --git a/test/jobs/long.js b/test/jobs/long.js index 34034bf..bd421d9 100644 --- a/test/jobs/long.js +++ b/test/jobs/long.js @@ -2,6 +2,7 @@ const { parentPort } = require('worker_threads'); setTimeout(() => { console.log('hello'); + process.exit(0); }, 10000); if (parentPort) {