ep_font_size
Advanced tools
Comparing version 0.4.59 to 0.4.60
{ | ||
"description": "Apply sizes to fonts", | ||
"name": "ep_font_size", | ||
"version": "0.4.59", | ||
"version": "0.4.60", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -5,26 +5,28 @@ 'use strict'; | ||
const randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; | ||
import {generateJWTToken, generateJWTTokenUser} from "ep_etherpad-lite/tests/backend/common"; | ||
let agent; | ||
const apiVersion = 1; | ||
const apiKey = common.apiKey; | ||
// Creates a pad and returns the pad id. Calls the callback when finished. | ||
const createPad = (padID, callback) => { | ||
agent.get(`/api/${apiVersion}/createPad?apikey=${apiKey}&padID=${padID}`) | ||
.end((err, res) => { | ||
if (err || (res.body.code !== 0)) callback(new Error('Unable to create new Pad')); | ||
callback(padID); | ||
}); | ||
const createPad = async (padID, callback) => { | ||
agent.get(`/api/${apiVersion}/createPad?padID=${padID}`) | ||
.set("Authorization", await generateJWTToken()) | ||
.end((err, res) => { | ||
if (err || (res.body.code !== 0)) callback(new Error('Unable to create new Pad')); | ||
callback(padID); | ||
}); | ||
}; | ||
const setHTML = (padID, html, callback) => { | ||
agent.get(`/api/${apiVersion}/setHTML?apikey=${apiKey}&padID=${padID}&html=${html}`) | ||
.end((err, res) => { | ||
if (err || (res.body.code !== 0)) callback(new Error('Unable to set pad HTML')); | ||
callback(null, padID); | ||
}); | ||
const setHTML = async (padID, html, callback) => { | ||
agent.get(`/api/${apiVersion}/setHTML?padID=${padID}&html=${html}`) | ||
.set("Authorization", await generateJWTToken()) | ||
.end((err, res) => { | ||
if (err || (res.body.code !== 0)) callback(new Error('Unable to set pad HTML')); | ||
callback(null, padID); | ||
}); | ||
}; | ||
const getHTMLEndPointFor = | ||
(padID, callback) => `/api/${apiVersion}/getHTML?apikey=${apiKey}&padID=${padID}`; | ||
(padID, callback) => `/api/${apiVersion}/getHTML?&padID=${padID}`; | ||
@@ -76,22 +78,21 @@ const codeToBe = (expectedCode, res) => { | ||
it('returns ok', function (done) { | ||
agent.get(getHTMLEndPointFor(padID)) | ||
.expect(codeToBe0) | ||
.expect('Content-Type', /json/) | ||
.expect(200, done); | ||
it('returns ok', async function () { | ||
await agent.get(getHTMLEndPointFor(padID)) | ||
.set("Authorization", await generateJWTToken()) | ||
.expect(codeToBe0) | ||
.expect('Content-Type', /json/) | ||
.expect(200); | ||
}); | ||
it('returns HTML with size class', function (done) { | ||
agent.get(getHTMLEndPointFor(padID)) | ||
.expect((res) => { | ||
const expectedRegex = regexWithSize('8'); | ||
const expectedsizes = new RegExp(expectedRegex); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(expectedsizes); | ||
if (!foundsize) { | ||
throw new Error( | ||
`size not exported. Regex used: ${expectedRegex}, html exported: ${html}`); | ||
} | ||
}) | ||
.end(done); | ||
it('returns HTML with size class', async function () { | ||
const res = await agent.get(getHTMLEndPointFor(padID)) | ||
.set("Authorization", await generateJWTToken()); | ||
const expectedRegex = regexWithSize('8'); | ||
const expectedsizes = new RegExp(expectedRegex); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(expectedsizes); | ||
if (!foundsize) { | ||
throw new Error( | ||
`size not exported. Regex used: ${expectedRegex}, html exported: ${html}`); | ||
} | ||
}); | ||
@@ -105,18 +106,16 @@ }); | ||
it('returns HTML with two size spans', function (done) { | ||
agent.get(getHTMLEndPointFor(padID)) | ||
.expect((res) => { | ||
const firstsize = regexWithSize('8'); | ||
const secondsize = regexWithSize('9'); | ||
const expectedRegex = `${firstsize}.*${secondsize}`; | ||
const expectedsizes = new RegExp(expectedRegex); | ||
it('returns HTML with two size spans', async function () { | ||
const res = await agent.get(getHTMLEndPointFor(padID)) | ||
.set("Authorization", await generateJWTToken()); | ||
const firstsize = regexWithSize('8'); | ||
const secondsize = regexWithSize('9'); | ||
const expectedRegex = `${firstsize}.*${secondsize}`; | ||
const expectedsizes = new RegExp(expectedRegex); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(expectedsizes); | ||
if (!foundsize) { | ||
throw new Error( | ||
`size not exported. Regex used: ${expectedRegex}, html exported: ${html}`); | ||
} | ||
}) | ||
.end(done); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(expectedsizes); | ||
if (!foundsize) { | ||
throw new Error( | ||
`size not exported. Regex used: ${expectedRegex}, html exported: ${html}`); | ||
} | ||
}); | ||
@@ -130,16 +129,14 @@ }); | ||
it('returns HTML with no size', function (done) { | ||
agent.get(getHTMLEndPointFor(padID)) | ||
.expect((res) => { | ||
const expectedRegex = '.*empty pad.*'; | ||
const nosize = new RegExp(expectedRegex); | ||
it('returns HTML with no size', async function () { | ||
const res = await agent.get(getHTMLEndPointFor(padID)) | ||
.set("Authorization", await generateJWTToken()); | ||
const expectedRegex = '.*empty pad.*'; | ||
const nosize = new RegExp(expectedRegex); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(nosize); | ||
if (!foundsize) { | ||
throw new Error('size exported, should not have any. ' + | ||
`Regex used: ${expectedRegex}, html exported: ${html}`); | ||
} | ||
}) | ||
.end(done); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(nosize); | ||
if (!foundsize) { | ||
throw new Error('size exported, should not have any. ' + | ||
`Regex used: ${expectedRegex}, html exported: ${html}`); | ||
} | ||
}); | ||
@@ -155,16 +152,14 @@ }); | ||
// size) | ||
it('returns HTML with strong and size, in any order', function (done) { | ||
agent.get(getHTMLEndPointFor(padID)) | ||
.expect((res) => { | ||
const txt = 'this is size 8 and bold'; | ||
const strongInside = new RegExp(regexWithSize('8', `<strong>${txt}</strong>`)); | ||
const sizeInside = new RegExp(`<strong>${regexWithSize('8', txt)}</strong>`); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(strongInside) || html.match(sizeInside); | ||
if (!foundsize) { | ||
throw new Error(`size not exported. Regex used: [${strongInside.source} || ` + | ||
`${sizeInside.source}], html exported: ${html}`); | ||
} | ||
}) | ||
.end(done); | ||
it('returns HTML with strong and size, in any order', async function () { | ||
const res = await agent.get(getHTMLEndPointFor(padID)) | ||
.set("Authorization", await generateJWTToken()); | ||
const txt = 'this is size 8 and bold'; | ||
const strongInside = new RegExp(regexWithSize('8', `<strong>${txt}</strong>`)); | ||
const sizeInside = new RegExp(`<strong>${regexWithSize('8', txt)}</strong>`); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(strongInside) || html.match(sizeInside); | ||
if (!foundsize) { | ||
throw new Error(`size not exported. Regex used: [${strongInside.source} || ` + | ||
`${sizeInside.source}], html exported: ${html}`); | ||
} | ||
}); | ||
@@ -180,16 +175,14 @@ }); | ||
// size) | ||
it('returns HTML with strong and size, in any order', function (done) { | ||
agent.get(getHTMLEndPointFor(padID)) | ||
.expect((res) => { | ||
const txt = 'this is size 8 and bold'; | ||
const strongInside = new RegExp(regexWithSize('8', `<strong>${txt}</strong>`)); | ||
const sizeInside = new RegExp(`<strong>${regexWithSize('8', txt)}</strong>`); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(strongInside) || html.match(sizeInside); | ||
if (!foundsize) { | ||
throw new Error(`size not exported. Regex used: [${strongInside.source} || ` + | ||
`${sizeInside.source}], html exported: ${html}`); | ||
} | ||
}) | ||
.end(done); | ||
it('returns HTML with strong and size, in any order', async function () { | ||
const res = await agent.get(getHTMLEndPointFor(padID)) | ||
.set("Authorization", await generateJWTToken()) | ||
const txt = 'this is size 8 and bold'; | ||
const strongInside = new RegExp(regexWithSize('8', `<strong>${txt}</strong>`)); | ||
const sizeInside = new RegExp(`<strong>${regexWithSize('8', txt)}</strong>`); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(strongInside) || html.match(sizeInside); | ||
if (!foundsize) { | ||
throw new Error(`size not exported. Regex used: [${strongInside.source} || ` + | ||
`${sizeInside.source}], html exported: ${html}`); | ||
} | ||
}); | ||
@@ -203,17 +196,15 @@ }); | ||
it('returns HTML with part with size and part without it', function (done) { | ||
agent.get(getHTMLEndPointFor(padID)) | ||
.expect((res) => { | ||
const expectedRegex = `no size here ${regexWithSize('8')}`; | ||
const expectedsizes = new RegExp(expectedRegex); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(expectedsizes); | ||
if (!foundsize) { | ||
throw new Error( | ||
`size not exported. Regex used: ${expectedRegex}, html exported: ${html}`); | ||
} | ||
}) | ||
.end(done); | ||
it('returns HTML with part with size and part without it', async function () { | ||
const res = await agent.get(getHTMLEndPointFor(padID)) | ||
.set("Authorization", await generateJWTToken()); | ||
const expectedRegex = `no size here ${regexWithSize('8')}`; | ||
const expectedsizes = new RegExp(expectedRegex); | ||
const html = res.body.data.html; | ||
const foundsize = html.match(expectedsizes); | ||
if (!foundsize) { | ||
throw new Error( | ||
`size not exported. Regex used: ${expectedRegex}, html exported: ${html}`); | ||
} | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61587
896