'use strict'; const common = require('ep_etherpad-lite/tests/backend/common'); let agent; const apiVersion = 1; const randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; import {generateJWTToken} from "ep_etherpad-lite/tests/backend/common"; // Creates a pad and returns the pad id. Calls the callback when finished. const createPad = async (padID: string) => { const res = await agent.get(`/api/${apiVersion}/createPad?padID=${padID}`) .set("Authorization", await generateJWTToken()) return new Promise((resolve, reject) => { if (res.body.code !== 0) { reject(new Error('Unable to create new Pad')); } else { resolve(padID); } }) }; const setHTML = async (padID: string, html: string) => { const newHtml = `/api/${apiVersion}/setHTML?padID=${padID}&html=${html}` console.log("New HTML is",newHtml) const res = await agent.get(newHtml) .set("authorization", await generateJWTToken()) console.log("Res is",res.body) return new Promise((resolve, reject) => { if (res.body.code !== 0) { reject(new Error('Unable to set pad HTML')); } else { resolve(padID); } }) }; const getHTMLEndPointFor = (padID: string) => `/api/${apiVersion}/getHTML?padID=${padID}`; const buildHTML = (body: string) => `
${body}`; describe('export alignment to HTML', function () { let padID; let html; before(async function () { agent = await common.init(); }); // create a new pad before each test run beforeEach(async function () { padID = randomString(5); await createPad(padID); await setHTML(padID, html()); }); context('when pad text is center aligned', function () { before(async function () { html = () => buildHTML('Hello world