From 98c42d607693927c5523b983c91658fb1a30d2cd Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 17 Mar 2021 15:37:12 -0400 Subject: [PATCH] tests: Promisify import/export tests --- src/tests/backend/specs/api/importexport.js | 43 +++++++++++---------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/tests/backend/specs/api/importexport.js b/src/tests/backend/specs/api/importexport.js index 6c74cd977..1626d3e6e 100644 --- a/src/tests/backend/specs/api/importexport.js +++ b/src/tests/backend/specs/api/importexport.js @@ -239,27 +239,30 @@ describe(__filename, function () { done(); }); } - it('createPad', function (done) { - agent.get(`${endPoint('createPad')}&padID=${testPadId}`) + + it('createPad', async function () { + await agent.get(`${endPoint('createPad')}&padID=${testPadId}`) + .expect(200) + .expect('Content-Type', /json/) .expect((res) => { if (res.body.code !== 0) throw new Error('Unable to create new Pad'); - }) - .expect('Content-Type', /json/) - .expect(200, done); + }); }); - it('setHTML', function (done) { - agent.get(`${endPoint('setHTML')}&padID=${testPadId}` + - `&html=${encodeURIComponent(test.input)}`) + it('setHTML', async function () { + await agent.get(`${endPoint('setHTML')}&padID=${testPadId}` + + `&html=${encodeURIComponent(test.input)}`) + .expect(200) + .expect('Content-Type', /json/) .expect((res) => { if (res.body.code !== 0) throw new Error(`Error:${testName}`); - }) - .expect('Content-Type', /json/) - .expect(200, done); + }); }); - it('getHTML', function (done) { - agent.get(`${endPoint('getHTML')}&padID=${testPadId}`) + it('getHTML', async function () { + await agent.get(`${endPoint('getHTML')}&padID=${testPadId}`) + .expect(200) + .expect('Content-Type', /json/) .expect((res) => { const gotHtml = res.body.data.html; if (gotHtml !== test.wantHTML) { @@ -276,13 +279,13 @@ describe(__filename, function () { Which is a different version of the originally imported one: ${test.input}`); } - }) - .expect('Content-Type', /json/) - .expect(200, done); + }); }); - it('getText', function (done) { - agent.get(`${endPoint('getText')}&padID=${testPadId}`) + it('getText', async function () { + await agent.get(`${endPoint('getText')}&padID=${testPadId}`) + .expect(200) + .expect('Content-Type', /json/) .expect((res) => { const gotText = res.body.data.text; if (gotText !== test.wantText) { @@ -299,9 +302,7 @@ describe(__filename, function () { Which is a different version of the originally imported one: ${test.input}`); } - }) - .expect('Content-Type', /json/) - .expect(200, done); + }); }); }); });