ep_headings2 0.2.61 → 0.2.63

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "Adds heading support to Etherpad Lite. Includes improved suppot for export, i18n etc.",
3
3
  "name": "ep_headings2",
4
- "version": "0.2.61",
4
+ "version": "0.2.63",
5
5
  "author": {
6
6
  "name": "John McLear",
7
7
  "email": "john@mclear.co.uk"
@@ -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?apikey=${apiKey}&padID=${padID}`)
13
- .end((err, res) => {
14
- if (err || (res.body.code !== 0)) callback(new Error('Unable to create new Pad'));
15
- callback(padID);
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?apikey=${apiKey}&padID=${padID}&html=${html}`)
21
- .end((err, res) => {
22
- if (err || (res.body.code !== 0)) callback(new Error('Unable to set pad HTML'));
23
- callback(null, padID);
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?apikey=${apiKey}&padID=${padID}`;
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,18 @@ 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) {
53
- agent.get(getHTMLEndPointFor(padID))
54
- .expect('Content-Type', /json/)
55
- .expect(200, done);
54
+ it('returns ok', async function () {
55
+ await agent.get(getHTMLEndPointFor(padID))
56
+ .set("Authorization", await generateJWTToken())
57
+ .expect('Content-Type', /json/)
58
+ .expect(200);
56
59
  });
57
60
 
58
- it('returns HTML with Headings HTML tags', function (done) {
59
- agent.get(getHTMLEndPointFor(padID))
60
- .expect((res) => {
61
- const html = res.body.data.html;
62
- if (html.indexOf('<h1>Hello world</h1>') === -1) throw new Error('No H1 tag detected');
63
- })
64
- .end(done);
61
+ it('returns HTML with Headings HTML tags', async function () {
62
+ const res = await agent.get(getHTMLEndPointFor(padID))
63
+ .set("Authorization", await generateJWTToken());
64
+ const html = res.body.data.html;
65
+ if (html.indexOf('<h1>Hello world</h1>') === -1) throw new Error('No H1 tag detected');
65
66
  });
66
67
  });
67
68
 
@@ -70,20 +71,19 @@ describe('ep_headings2 - export headings to HTML', function () {
70
71
  html = () => buildHTML('<h1>Hello world</h1><br/><h2>Foo</h2>');
71
72
  });
72
73
 
73
- it('returns ok', function (done) {
74
- agent.get(getHTMLEndPointFor(padID))
75
- .expect('Content-Type', /json/)
76
- .expect(200, done);
74
+ it('returns ok', async function () {
75
+ await agent.get(getHTMLEndPointFor(padID))
76
+ .set("Authorization", await generateJWTToken())
77
+ .expect('Content-Type', /json/)
78
+ .expect(200);
77
79
  });
78
80
 
79
- it('returns HTML with Multiple Headings HTML tags', function (done) {
80
- agent.get(getHTMLEndPointFor(padID))
81
- .expect((res) => {
82
- const html = res.body.data.html;
83
- if (html.indexOf('<h1>Hello world</h1>') === -1) throw new Error('No H1 tag detected');
84
- if (html.indexOf('<h2>Foo</h2>') === -1) throw new Error('No H2 tag detected');
85
- })
86
- .end(done);
81
+ it('returns HTML with Multiple Headings HTML tags', async function () {
82
+ const res = await agent.get(getHTMLEndPointFor(padID))
83
+ .set("Authorization", await generateJWTToken())
84
+ const html = res.body.data.html;
85
+ if (html.indexOf('<h1>Hello world</h1>') === -1) throw new Error('No H1 tag detected');
86
+ if (html.indexOf('<h2>Foo</h2>') === -1) throw new Error('No H2 tag detected');
87
87
  });
88
88
  });
89
89
 
@@ -92,33 +92,31 @@ describe('ep_headings2 - export headings to HTML', function () {
92
92
  html = () => buildHTML('<h1><left>Hello world</left></h1><br/><h2><center>Foo</center></h2>');
93
93
  });
94
94
 
95
- it('returns ok', function (done) {
96
- agent.get(getHTMLEndPointFor(padID))
97
- .expect('Content-Type', /json/)
98
- .expect(200, done);
95
+ it('returns ok', async function () {
96
+ await agent.get(getHTMLEndPointFor(padID))
97
+ .set("Authorization", await generateJWTToken())
98
+ .expect('Content-Type', /json/)
99
+ .expect(200);
99
100
  });
100
101
 
101
- it('returns HTML with Multiple Headings HTML tags', function (done) {
102
+ it('returns HTML with Multiple Headings HTML tags', async function () {
102
103
  try {
103
104
  // eslint-disable-next-line n/no-extraneous-require, n/no-missing-require
104
105
  require.resolve('ep_align');
105
- agent.get(getHTMLEndPointFor(padID))
106
- .expect((res) => {
107
- const html = res.body.data.html;
108
- console.warn('HTML', html);
109
- if (html.indexOf('<h1 style=\'text-align:left\'>Hello world</h1>') === -1) {
110
- throw new Error('No H1 tag detected');
111
- }
112
- if (html.indexOf('<h2 style=\'text-align:center\'>Foo</h2>') === -1) {
113
- throw new Error('No H2 tag detected');
114
- }
115
- })
116
- .end(done);
106
+ const res = await agent.get(getHTMLEndPointFor(padID))
107
+ .set("Authorization", await generateJWTToken());
108
+ const html = res.body.data.html;
109
+ console.warn('HTML', html);
110
+ if (html.search(/<h1 +style='text-align:left'>Hello world<\/h1>/) === -1) {
111
+ throw new Error('No H1 tag detected');
112
+ }
113
+ if (html.search(/<h2 +style='text-align:center'>Foo<\/h2>/) === -1) {
114
+ throw new Error('No H2 tag detected');
115
+ }
117
116
  } catch (e) {
118
117
  if (e.message.indexOf('Cannot find module') === -1) {
119
118
  throw new Error(e.message);
120
119
  }
121
- done();
122
120
  }
123
121
  });
124
122
  });