ep_subscript_and_superscript 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
"url": "https://github.com/ether/ep_subscript_and_superscript/issues"
|
|
8
8
|
},
|
|
9
9
|
"bundleDependencies": [],
|
|
10
|
-
"dependencies": {},
|
|
11
10
|
"deprecated": false,
|
|
12
11
|
"description": "Add support for different Fonts",
|
|
13
12
|
"engines": {
|
|
@@ -20,14 +19,17 @@
|
|
|
20
19
|
"type": "git",
|
|
21
20
|
"url": "git+https://github.com/ether/ep_subscript_and_superscript.git"
|
|
22
21
|
},
|
|
23
|
-
"version": "0.3.
|
|
22
|
+
"version": "0.3.7",
|
|
24
23
|
"funding": {
|
|
25
24
|
"type": "individual",
|
|
26
25
|
"url": "https://etherpad.org/"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
28
|
+
"@types/mocha": "^10.0.6",
|
|
29
|
+
"@types/node": "^20.11.30",
|
|
29
30
|
"eslint": "^8.57.0",
|
|
30
31
|
"eslint-config-etherpad": "^4.0.4",
|
|
32
|
+
"mocha": "^10.4.0",
|
|
31
33
|
"typescript": "^5.4.3"
|
|
32
34
|
},
|
|
33
35
|
"scripts": {
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const common = require('ep_etherpad-lite/tests/backend/common');
|
|
4
|
+
const randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
|
|
5
|
+
import {generateJWTToken} from "ep_etherpad-lite/tests/backend/common";
|
|
6
|
+
|
|
7
|
+
let agent;
|
|
8
|
+
const apiVersion = 1;
|
|
9
|
+
|
|
10
|
+
const buildHTML = (body: string) => `<html><body>${body}</body></html>`;
|
|
11
|
+
const getHTMLEndPointFor = (padID: string) => `/api/${apiVersion}/getHTML?padID=${padID}`;
|
|
12
|
+
|
|
13
|
+
// Creates a pad and returns the pad id. Calls the callback when finished.
|
|
14
|
+
const createPad = async (padID: string) => {
|
|
15
|
+
const token = await generateJWTToken();
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
agent.get(`/api/${apiVersion}/createPad?padID=${padID}`)
|
|
18
|
+
.set("Authorization", token)
|
|
19
|
+
.end((err, res) => {
|
|
20
|
+
if (err || (res.body.code !== 0)) {
|
|
21
|
+
reject(new Error('Unable to create new Pad'));
|
|
22
|
+
} else {
|
|
23
|
+
resolve(padID);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const setHTML = async (padID: string, html: string) => {
|
|
29
|
+
const token = await generateJWTToken();
|
|
30
|
+
return await new Promise((resolve, reject) => {
|
|
31
|
+
agent.get(`/api/${apiVersion}/setHTML?padID=${padID}&html=${html}`)
|
|
32
|
+
.set("Authorization", token)
|
|
33
|
+
.end((err, res) => {
|
|
34
|
+
if (err || (res.body.code !== 0)) {
|
|
35
|
+
reject(new Error('Unable to set pad HTML'));
|
|
36
|
+
} else {
|
|
37
|
+
resolve(padID);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
describe('export Subscript to HTML', function () {
|
|
44
|
+
let padID: string;
|
|
45
|
+
let html: Function;
|
|
46
|
+
|
|
47
|
+
before(async function () { agent = await common.init(); });
|
|
48
|
+
|
|
49
|
+
// create a new pad before each test run
|
|
50
|
+
beforeEach(async function () {
|
|
51
|
+
padID = randomString(5);
|
|
52
|
+
await createPad(padID);
|
|
53
|
+
await setHTML(padID, html());
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
context('when pad text has one Subscript', function () {
|
|
57
|
+
before(function () {
|
|
58
|
+
html = () => buildHTML('<sub>Hello world</sub>');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('returns ok', async function () {
|
|
62
|
+
await agent.get(getHTMLEndPointFor(padID))
|
|
63
|
+
.set("Authorization", await generateJWTToken())
|
|
64
|
+
.expect('Content-Type', /json/)
|
|
65
|
+
.expect(200);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('returns HTML with Subscript HTML tags', async function () {
|
|
69
|
+
const res = await agent.get(getHTMLEndPointFor(padID))
|
|
70
|
+
.set("Authorization", await generateJWTToken());
|
|
71
|
+
|
|
72
|
+
const html = res.body.data.html;
|
|
73
|
+
if (html.indexOf('<sub>Hello world</sub>') === -1) {
|
|
74
|
+
throw new Error('No sub tag detected');
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
context('when pad text has multiple Subscripts on multiple lines', function () {
|
|
80
|
+
before(async function () {
|
|
81
|
+
html = () => buildHTML('<sub>Hello world</sub><br/><sub>Foo</sub>');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
it('returns ok', async function () {
|
|
86
|
+
await agent.get(getHTMLEndPointFor(padID))
|
|
87
|
+
.set("Authorization", await generateJWTToken())
|
|
88
|
+
.expect('Content-Type', /json/)
|
|
89
|
+
.expect(200);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('returns HTML with Multiple Subscripts HTML tags', async function () {
|
|
93
|
+
const res = await agent.get(getHTMLEndPointFor(padID))
|
|
94
|
+
.set("Authorization", await generateJWTToken());
|
|
95
|
+
|
|
96
|
+
const html = res.body.data.html;
|
|
97
|
+
if (html.indexOf('<sub>Hello world</sub>') === -1) {
|
|
98
|
+
throw new Error('No sub tag detected');
|
|
99
|
+
}
|
|
100
|
+
if (html.indexOf('<sub>Foo</sub>') === -1) {
|
|
101
|
+
throw new Error('No sub tag detected');
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('export Superscript to HTML', function () {
|
|
108
|
+
let padID;
|
|
109
|
+
let html;
|
|
110
|
+
|
|
111
|
+
// create a new pad before each test run
|
|
112
|
+
beforeEach(async function () {
|
|
113
|
+
padID = randomString(5);
|
|
114
|
+
await createPad(padID)
|
|
115
|
+
await setHTML(padID, html());
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
context('when pad text has one Superscript', function () {
|
|
119
|
+
before(function (done) {
|
|
120
|
+
html = () => buildHTML('<sup>Hello world</sup>');
|
|
121
|
+
done();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
it('returns ok', async function () {
|
|
126
|
+
await agent.get(getHTMLEndPointFor(padID))
|
|
127
|
+
.set("Authorization", await generateJWTToken())
|
|
128
|
+
.expect('Content-Type', /json/)
|
|
129
|
+
.expect(200);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('returns HTML with Superscript HTML tags', async function () {
|
|
133
|
+
const res = await agent.get(getHTMLEndPointFor(padID))
|
|
134
|
+
.set("Authorization", await generateJWTToken());
|
|
135
|
+
|
|
136
|
+
const html = res.body.data.html;
|
|
137
|
+
if (html.indexOf('<sup>Hello world</sup>') === -1) {
|
|
138
|
+
throw new Error('No sup tag detected');
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
context('when pad text has multiple Superscripts on multiple lines', function () {
|
|
144
|
+
before(async function () {
|
|
145
|
+
html = () => buildHTML('<sup>Hello world</sup><br/><sup>Foo</sup>');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('returns ok', async function () {
|
|
149
|
+
return await agent.get(getHTMLEndPointFor(padID))
|
|
150
|
+
.set("Authorization", await generateJWTToken())
|
|
151
|
+
.expect('Content-Type', /json/)
|
|
152
|
+
.expect(200);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('returns HTML with Multiple Superscripts HTML tags', async function () {
|
|
156
|
+
const res = await agent.get(getHTMLEndPointFor(padID))
|
|
157
|
+
.set("Authorization", await generateJWTToken());
|
|
158
|
+
|
|
159
|
+
const html = res.body.data.html;
|
|
160
|
+
if (html.indexOf('<sup>Hello world</sup>') === -1) {
|
|
161
|
+
throw new Error('No sup tag detected');
|
|
162
|
+
}
|
|
163
|
+
if (html.indexOf('<sup>Foo</sup>') === -1) {
|
|
164
|
+
throw new Error('No sup tag detected');
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const common = require('ep_etherpad-lite/tests/backend/common');
|
|
4
|
-
const randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
|
|
5
|
-
import {generateJWTToken, generateJWTTokenUser} from "ep_etherpad-lite/tests/backend/common";
|
|
6
|
-
|
|
7
|
-
let agent;
|
|
8
|
-
const apiVersion = 1;
|
|
9
|
-
|
|
10
|
-
const buildHTML = (body) => `<html><body>${body}</body></html>`;
|
|
11
|
-
const getHTMLEndPointFor =
|
|
12
|
-
(padID, callback) => `/api/${apiVersion}/getHTML?padID=${padID}`;
|
|
13
|
-
|
|
14
|
-
// Creates a pad and returns the pad id. Calls the callback when finished.
|
|
15
|
-
const createPad = async (padID, callback) => {
|
|
16
|
-
agent.get(`/api/${apiVersion}/createPad?padID=${padID}`)
|
|
17
|
-
.set("Authorization", await generateJWTToken())
|
|
18
|
-
.end((err, res) => {
|
|
19
|
-
if (err || (res.body.code !== 0)) callback(new Error('Unable to create new Pad'));
|
|
20
|
-
|
|
21
|
-
callback(padID);
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const setHTML = async (padID, html, callback) => {
|
|
26
|
-
agent.get(`/api/${apiVersion}/setHTML?padID=${padID}&html=${html}`)
|
|
27
|
-
.set("Authorization", await generateJWTToken())
|
|
28
|
-
.end((err, res) => {
|
|
29
|
-
if (err || (res.body.code !== 0)) callback(new Error('Unable to set pad HTML'));
|
|
30
|
-
|
|
31
|
-
callback(null, padID);
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
describe('export Subscript to HTML', function () {
|
|
36
|
-
let padID;
|
|
37
|
-
let html;
|
|
38
|
-
|
|
39
|
-
before(async function () { agent = await common.init(); });
|
|
40
|
-
|
|
41
|
-
// create a new pad before each test run
|
|
42
|
-
beforeEach(async function (done) {
|
|
43
|
-
padID = randomString(5);
|
|
44
|
-
|
|
45
|
-
await createPad(padID, async () => {
|
|
46
|
-
await setHTML(padID, html(), done);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
context('when pad text has one Subscript', function () {
|
|
51
|
-
before(async function () {
|
|
52
|
-
html = () => buildHTML('<sub>Hello world</sub>');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('returns ok', async function (done) {
|
|
56
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
57
|
-
.set("Authorization", await generateJWTToken())
|
|
58
|
-
.expect('Content-Type', /json/)
|
|
59
|
-
.expect(200, done);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('returns HTML with Subscript HTML tags', async function (done) {
|
|
63
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
64
|
-
.set("Authorization", await generateJWTToken())
|
|
65
|
-
.expect((res) => {
|
|
66
|
-
const html = res.body.data.html;
|
|
67
|
-
if (html.indexOf('<sub>Hello world</sub>') === -1) {
|
|
68
|
-
throw new Error('No sub tag detected');
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
.end(done);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
context('when pad text has multiple Subscripts on multiple lines', function () {
|
|
76
|
-
before(async function () {
|
|
77
|
-
html = () => buildHTML('<sub>Hello world</sub><br/><sub>Foo</sub>');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
it('returns ok', async function (done) {
|
|
82
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
83
|
-
.set("Authorization", await generateJWTToken())
|
|
84
|
-
.expect('Content-Type', /json/)
|
|
85
|
-
.expect(200, done);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('returns HTML with Multiple Subscripts HTML tags', async function (done) {
|
|
89
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
90
|
-
.set("Authorization", await generateJWTToken())
|
|
91
|
-
.expect((res) => {
|
|
92
|
-
const html = res.body.data.html;
|
|
93
|
-
if (html.indexOf('<sub>Hello world</sub>') === -1) {
|
|
94
|
-
throw new Error('No sub tag detected');
|
|
95
|
-
}
|
|
96
|
-
if (html.indexOf('<sub>Foo</sub>') === -1) throw new Error('No sub tag detected');
|
|
97
|
-
})
|
|
98
|
-
.end(done);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
describe('export Superscript to HTML', function () {
|
|
104
|
-
let padID;
|
|
105
|
-
let html;
|
|
106
|
-
|
|
107
|
-
// create a new pad before each test run
|
|
108
|
-
beforeEach(function (done) {
|
|
109
|
-
padID = randomString(5);
|
|
110
|
-
|
|
111
|
-
createPad(padID, () => {
|
|
112
|
-
setHTML(padID, html(), done);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
context('when pad text has one Superscript', function () {
|
|
117
|
-
before(async function () {
|
|
118
|
-
html = () => buildHTML('<sup>Hello world</sup>');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
it('returns ok', async function (done) {
|
|
123
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
124
|
-
.set("Authorization", await generateJWTToken())
|
|
125
|
-
.expect('Content-Type', /json/)
|
|
126
|
-
.expect(200, done);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('returns HTML with Suberscript HTML tags', async function (done) {
|
|
130
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
131
|
-
.set("Authorization", await generateJWTToken())
|
|
132
|
-
.expect((res) => {
|
|
133
|
-
const html = res.body.data.html;
|
|
134
|
-
if (html.indexOf('<sup>Hello world</sup>') === -1) {
|
|
135
|
-
throw new Error('No sup tag detected');
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
.end(done);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
context('when pad text has multiple Superscripts on multiple lines', function () {
|
|
143
|
-
before(async function () {
|
|
144
|
-
html = () => buildHTML('<sup>Hello world</sup><br/><sup>Foo</sup>');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('returns ok', async function (done) {
|
|
148
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
149
|
-
.set("Authorization", await generateJWTToken())
|
|
150
|
-
.expect('Content-Type', /json/)
|
|
151
|
-
.expect(200, done);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('returns HTML with Multiple Superscripts HTML tags', async function (done) {
|
|
155
|
-
agent.get(getHTMLEndPointFor(padID))
|
|
156
|
-
.set("Authorization", await generateJWTToken())
|
|
157
|
-
.expect((res) => {
|
|
158
|
-
const html = res.body.data.html;
|
|
159
|
-
if (html.indexOf('<sup>Hello world</sup>') === -1) {
|
|
160
|
-
throw new Error('No sup tag detected');
|
|
161
|
-
}
|
|
162
|
-
if (html.indexOf('<sup>Foo</sup>') === -1) {
|
|
163
|
-
throw new Error('No sup tag detected');
|
|
164
|
-
}
|
|
165
|
-
})
|
|
166
|
-
.end(done);
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
});
|