From cd6da7335bca7a76fabd40eb7fd7efd7b709305d Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Sat, 29 Jul 2023 21:21:06 +0200 Subject: [PATCH] tests: fix for appendRevision test --- src/tests/backend/specs/api/chat.js | 18 ------------------ src/tests/backend/specs/api/pad.js | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/tests/backend/specs/api/chat.js b/src/tests/backend/specs/api/chat.js index bfd637349..fcc69a363 100644 --- a/src/tests/backend/specs/api/chat.js +++ b/src/tests/backend/specs/api/chat.js @@ -49,24 +49,6 @@ describe(__filename, function () { }); }); - - describe('createPad with empty text', () => { - it('creates a new Pad with empty text', function (done) { - agent.get(`${endPoint('createPad')}&padID=${padID}&text=`) - .expect((res) => { - if (res.body.code !== 0) throw new Error('Unable to create new Pad'); - }) - .expect('Content-Type', /json/) - .expect(200); - agent.get(`${endPoint('deletePad')}&padID=${padID}`) - .expect((res) => { - if (res.body.code !== 0) throw new Error('Unable to delete empty Pad'); - }) - .expect('Content-Type', /json/) - .expect(200, done); - }); - }); - describe('createAuthor', function () { it('Creates an author with a name set', function (done) { agent.get(endPoint('createAuthor')) diff --git a/src/tests/backend/specs/api/pad.js b/src/tests/backend/specs/api/pad.js index 64f10f012..b8250741e 100644 --- a/src/tests/backend/specs/api/pad.js +++ b/src/tests/backend/specs/api/pad.js @@ -17,6 +17,7 @@ let apiVersion = 1; const testPadId = makeid(); const newPadId = makeid(); const copiedPadId = makeid(); +const anotherPadId = makeid(); let lastEdited = ''; const text = generateLongText(); @@ -502,6 +503,31 @@ describe(__filename, function () { .expect('Content-Type', /json/); assert.equal(res.body.data.revisions, revCount); }); + + it('creates a new Pad with empty text', async function () { + await agent.get(`${endPoint('createPad')}&padID=${anotherPadId}&text=`) + .expect('Content-Type', /json/) + .expect(200) + .expect((res) => { + assert.equal(res.body.code, 0, 'Unable to create new Pad'); + }); + await agent.get(`${endPoint('getText')}&padID=${anotherPadId}`) + .expect('Content-Type', /json/) + .expect(200) + .expect((res) => { + assert.equal(res.body.code, 0, 'Unable to get pad text'); + assert.equal(res.body.data.text, '\n', 'Pad text is not empty'); + }); + }); + + it('deletes with empty text', async function () { + await agent.get(`${endPoint('deletePad')}&padID=${anotherPadId}`) + .expect('Content-Type', /json/) + .expect(200) + .expect((res) => { + assert.equal(res.body.code, 0, 'Unable to delete empty Pad'); + }); + }); }); describe('copyPadWithoutHistory', function () {