ep_headings2 0.2.61 → 0.2.62
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
|
@@ -2,30 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
const common = require('ep_etherpad-lite/tests/backend/common');
|
|
4
4
|
const randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
|
|
5
|
+
import {generateJWTToken, generateJWTTokenUser} from "ep_etherpad-lite/tests/backend/common";
|
|
5
6
|
|
|
6
7
|
let agent;
|
|
7
|
-
const apiKey = common.apiKey;
|
|
8
8
|
const apiVersion = 1;
|
|
9
9
|
|
|
10
10
|
// Creates a pad and returns the pad id. Calls the callback when finished.
|
|
11
|
-
const createPad = (padID, callback) => {
|
|
12
|
-
agent.get(`/api/${apiVersion}/createPad
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const createPad = async (padID, callback) => {
|
|
12
|
+
agent.get(`/api/${apiVersion}/createPad?&padID=${padID}`)
|
|
13
|
+
.set("Authorization", await generateJWTToken())
|
|
14
|
+
.end((err, res) => {
|
|
15
|
+
if (err || (res.body.code !== 0)) callback(new Error('Unable to create new Pad'));
|
|
16
|
+
callback(padID);
|
|
17
|
+
});
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
const setHTML = (padID, html, callback) => {
|
|
20
|
-
agent.get(`/api/${apiVersion}/setHTML?
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const setHTML = async (padID, html, callback) => {
|
|
21
|
+
agent.get(`/api/${apiVersion}/setHTML?padID=${padID}&html=${html}`)
|
|
22
|
+
.set("Authorization", await generateJWTToken())
|
|
23
|
+
.end((err, res) => {
|
|
24
|
+
if (err || (res.body.code !== 0)) callback(new Error('Unable to set pad HTML'));
|
|
25
|
+
callback(null, padID);
|
|
26
|
+
});
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
const getHTMLEndPointFor =
|
|
28
|
-
(padID, callback) => `/api/${apiVersion}/getHTML?
|
|
30
|
+
(padID, callback) => `/api/${apiVersion}/getHTML?padID=${padID}`;
|
|
29
31
|
|
|
30
32
|
const buildHTML = (body) => `<html><body>${body}</body></html>`;
|
|
31
33
|
|
|
@@ -49,19 +51,21 @@ describe('ep_headings2 - export headings to HTML', function () {
|
|
|
49
51
|
html = () => buildHTML('<h1>Hello world</h1>');
|
|
50
52
|
});
|
|
51
53
|
|
|
52
|
-
it('returns ok', function (done) {
|
|
54
|
+
it('returns ok', async function (done) {
|
|
53
55
|
agent.get(getHTMLEndPointFor(padID))
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
.set("Authorization", await generateJWTToken())
|
|
57
|
+
.expect('Content-Type', /json/)
|
|
58
|
+
.expect(200, done);
|
|
56
59
|
});
|
|
57
60
|
|
|
58
|
-
it('returns HTML with Headings HTML tags', function (done) {
|
|
61
|
+
it('returns HTML with Headings HTML tags', async function (done) {
|
|
59
62
|
agent.get(getHTMLEndPointFor(padID))
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
.set("Authorization", await generateJWTToken())
|
|
64
|
+
.expect((res) => {
|
|
65
|
+
const html = res.body.data.html;
|
|
66
|
+
if (html.indexOf('<h1>Hello world</h1>') === -1) throw new Error('No H1 tag detected');
|
|
67
|
+
})
|
|
68
|
+
.end(done);
|
|
65
69
|
});
|
|
66
70
|
});
|
|
67
71
|
|
|
@@ -70,20 +74,22 @@ describe('ep_headings2 - export headings to HTML', function () {
|
|
|
70
74
|
html = () => buildHTML('<h1>Hello world</h1><br/><h2>Foo</h2>');
|
|
71
75
|
});
|
|
72
76
|
|
|
73
|
-
it('returns ok', function (done) {
|
|
77
|
+
it('returns ok', async function (done) {
|
|
74
78
|
agent.get(getHTMLEndPointFor(padID))
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
.set("Authorization", await generateJWTToken())
|
|
80
|
+
.expect('Content-Type', /json/)
|
|
81
|
+
.expect(200, done);
|
|
77
82
|
});
|
|
78
83
|
|
|
79
|
-
it('returns HTML with Multiple Headings HTML tags', function (done) {
|
|
84
|
+
it('returns HTML with Multiple Headings HTML tags', async function (done) {
|
|
80
85
|
agent.get(getHTMLEndPointFor(padID))
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
.set("Authorization", await generateJWTToken())
|
|
87
|
+
.expect((res) => {
|
|
88
|
+
const html = res.body.data.html;
|
|
89
|
+
if (html.indexOf('<h1>Hello world</h1>') === -1) throw new Error('No H1 tag detected');
|
|
90
|
+
if (html.indexOf('<h2>Foo</h2>') === -1) throw new Error('No H2 tag detected');
|
|
91
|
+
})
|
|
92
|
+
.end(done);
|
|
87
93
|
});
|
|
88
94
|
});
|
|
89
95
|
|
|
@@ -92,28 +98,30 @@ describe('ep_headings2 - export headings to HTML', function () {
|
|
|
92
98
|
html = () => buildHTML('<h1><left>Hello world</left></h1><br/><h2><center>Foo</center></h2>');
|
|
93
99
|
});
|
|
94
100
|
|
|
95
|
-
it('returns ok', function (done) {
|
|
101
|
+
it('returns ok', async function (done) {
|
|
96
102
|
agent.get(getHTMLEndPointFor(padID))
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
.set("Authorization", await generateJWTToken())
|
|
104
|
+
.expect('Content-Type', /json/)
|
|
105
|
+
.expect(200, done);
|
|
99
106
|
});
|
|
100
107
|
|
|
101
|
-
it('returns HTML with Multiple Headings HTML tags', function (done) {
|
|
108
|
+
it('returns HTML with Multiple Headings HTML tags', async function (done) {
|
|
102
109
|
try {
|
|
103
110
|
// eslint-disable-next-line n/no-extraneous-require, n/no-missing-require
|
|
104
111
|
require.resolve('ep_align');
|
|
105
112
|
agent.get(getHTMLEndPointFor(padID))
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
113
|
+
.set("Authorization", await generateJWTToken())
|
|
114
|
+
.expect((res) => {
|
|
115
|
+
const html = res.body.data.html;
|
|
116
|
+
console.warn('HTML', html);
|
|
117
|
+
if (html.indexOf('<h1 style=\'text-align:left\'>Hello world</h1>') === -1) {
|
|
118
|
+
throw new Error('No H1 tag detected');
|
|
119
|
+
}
|
|
120
|
+
if (html.indexOf('<h2 style=\'text-align:center\'>Foo</h2>') === -1) {
|
|
121
|
+
throw new Error('No H2 tag detected');
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
.end(done);
|
|
117
125
|
} catch (e) {
|
|
118
126
|
if (e.message.indexOf('Cannot find module') === -1) {
|
|
119
127
|
throw new Error(e.message);
|