diff --git a/static/tests/backend/specs/exportHTML.js b/static/tests/backend/specs/exportHTML.js index d522180..3111404 100644 --- a/static/tests/backend/specs/exportHTML.js +++ b/static/tests/backend/specs/exportHTML.js @@ -51,21 +51,18 @@ describe('ep_headings2 - export headings to HTML', function () { html = () => buildHTML('

Hello world

'); }); - it('returns ok', async function (done) { - agent.get(getHTMLEndPointFor(padID)) + it('returns ok', async function () { + await agent.get(getHTMLEndPointFor(padID)) .set("Authorization", await generateJWTToken()) .expect('Content-Type', /json/) - .expect(200, done); + .expect(200); }); - it('returns HTML with Headings HTML tags', async function (done) { - agent.get(getHTMLEndPointFor(padID)) - .set("Authorization", await generateJWTToken()) - .expect((res) => { - const html = res.body.data.html; - if (html.indexOf('

Hello world

') === -1) throw new Error('No H1 tag detected'); - }) - .end(done); + it('returns HTML with Headings HTML tags', async function () { + const res = await agent.get(getHTMLEndPointFor(padID)) + .set("Authorization", await generateJWTToken()); + const html = res.body.data.html; + if (html.indexOf('

Hello world

') === -1) throw new Error('No H1 tag detected'); }); }); @@ -74,22 +71,19 @@ describe('ep_headings2 - export headings to HTML', function () { html = () => buildHTML('

Hello world


Foo

'); }); - it('returns ok', async function (done) { - agent.get(getHTMLEndPointFor(padID)) + it('returns ok', async function () { + await agent.get(getHTMLEndPointFor(padID)) .set("Authorization", await generateJWTToken()) .expect('Content-Type', /json/) - .expect(200, done); + .expect(200); }); - it('returns HTML with Multiple Headings HTML tags', async function (done) { - agent.get(getHTMLEndPointFor(padID)) + it('returns HTML with Multiple Headings HTML tags', async function () { + const res = await agent.get(getHTMLEndPointFor(padID)) .set("Authorization", await generateJWTToken()) - .expect((res) => { - const html = res.body.data.html; - if (html.indexOf('

Hello world

') === -1) throw new Error('No H1 tag detected'); - if (html.indexOf('

Foo

') === -1) throw new Error('No H2 tag detected'); - }) - .end(done); + const html = res.body.data.html; + if (html.indexOf('

Hello world

') === -1) throw new Error('No H1 tag detected'); + if (html.indexOf('

Foo

') === -1) throw new Error('No H2 tag detected'); }); }); @@ -98,35 +92,31 @@ describe('ep_headings2 - export headings to HTML', function () { html = () => buildHTML('

Hello world


Foo

'); }); - it('returns ok', async function (done) { - agent.get(getHTMLEndPointFor(padID)) + it('returns ok', async function () { + await agent.get(getHTMLEndPointFor(padID)) .set("Authorization", await generateJWTToken()) .expect('Content-Type', /json/) - .expect(200, done); + .expect(200); }); - it('returns HTML with Multiple Headings HTML tags', async function (done) { + it('returns HTML with Multiple Headings HTML tags', async function () { try { // eslint-disable-next-line n/no-extraneous-require, n/no-missing-require require.resolve('ep_align'); - agent.get(getHTMLEndPointFor(padID)) - .set("Authorization", await generateJWTToken()) - .expect((res) => { - const html = res.body.data.html; - console.warn('HTML', html); - if (html.indexOf('

Hello world

') === -1) { - throw new Error('No H1 tag detected'); - } - if (html.indexOf('

Foo

') === -1) { - throw new Error('No H2 tag detected'); - } - }) - .end(done); + const res = await agent.get(getHTMLEndPointFor(padID)) + .set("Authorization", await generateJWTToken()); + const html = res.body.data.html; + console.warn('HTML', html); + if (html.search(/

Hello world<\/h1>/) === -1) { + throw new Error('No H1 tag detected'); + } + if (html.search(/

Foo<\/h2>/) === -1) { + throw new Error('No H2 tag detected'); + } } catch (e) { if (e.message.indexOf('Cannot find module') === -1) { throw new Error(e.message); } - done(); } }); });