From bbca36a84d71226eda338d6fce0967c5c88e054b Mon Sep 17 00:00:00 2001 From: JasonEtco Date: Thu, 7 Dec 2017 20:09:00 -0500 Subject: [PATCH] Improve redeliver test --- tests/server.test.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/server.test.js b/tests/server.test.js index 260b7385..6a9c8bf0 100644 --- a/tests/server.test.js +++ b/tests/server.test.js @@ -56,15 +56,21 @@ describe('server', () => { done() }) }) - }) - it('POST /:channel/redeliver re-emits a payload', async () => { - const payload = { - foo: true, - bar: false - } + it('POST /:channel/redeliver re-emits a payload', async (done) => { + const payload = {payload: true} + + await request(server).post(channel + '/redeliver') + .send(payload) + .expect(200) + + events.addEventListener('message', (msg) => { + const data = JSON.parse(msg.data) + expect(data).toEqual(payload) - const res = await request(server).post('/jason/redeliver').send(payload) - expect(res.status).toBe(200) + // test is done if all of this gets called + done() + }) + }) }) })