jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/372207 )

Change subject: Hygiene: Split up tests for sectioning
......................................................................


Hygiene: Split up tests for sectioning

from parsoid-access.js to parsoid-sections-test.js

Change-Id: I9f86790b7275bb1be596a847490b7d79d7e72de1
---
M test/lib/parsoid/parsoid-access-test.js
A test/lib/parsoid/parsoid-sections-test.js
2 files changed, 74 insertions(+), 63 deletions(-)

Approvals:
  jenkins-bot: Verified
  Jdlrobson: Looks good to me, approved



diff --git a/test/lib/parsoid/parsoid-access-test.js 
b/test/lib/parsoid/parsoid-access-test.js
index b37e22f..fb0c433 100644
--- a/test/lib/parsoid/parsoid-access-test.js
+++ b/test/lib/parsoid/parsoid-access-test.js
@@ -4,10 +4,6 @@
 const domino = require('domino');
 const parsoid = require('../../../lib/parsoid-access');
 
-const html = '<body>text0' +
-    '<h2 id="foo">foo</h2>text1' +
-    '<h3 id="Funny_section_.21.40.23.24">Funny section !@#$%^&*()</h3>text2' +
-    '</body>';
 const headHtml1
     = `<html><head>
         <base href="//en.wikipedia.org/wiki/"/>
@@ -26,67 +22,9 @@
         </body>
        </html>`;
 
-describe('lib:parsoid', function() {
+describe('lib:parsoid-access', function() {
 
     this.timeout(20000); // eslint-disable-line no-invalid-this
-
-    function assertSection0(sections) {
-        assert.deepEqual(sections[0].id, 0);
-        assert.deepEqual(sections[0].text, 'text0', 
JSON.stringify(sections[0], null, 2));
-    }
-
-    function assertSection1(sections) {
-        assert.deepEqual(sections[1].id, 1);
-        assert.deepEqual(sections[1].toclevel, 1);
-        assert.deepEqual(sections[1].line, 'foo');
-        assert.deepEqual(sections[1].anchor, 'foo');
-        assert.deepEqual(sections[1].text, 'text1');
-    }
-
-    function assertSection2(sections) {
-        assert.deepEqual(sections[2].id, 2);
-        assert.deepEqual(sections[2].toclevel, 2);
-        // assert.deepEqual(sections[2].line, 'Funny section !@#$');
-        assert.deepEqual(sections[2].anchor, 'Funny_section_.21.40.23.24');
-        assert.deepEqual(sections[2].text, 'text2');
-    }
-
-
-    it('getSectionsText(empty) should produce an empty lead section', () => {
-        const doc = domino.createDocument('<body></body>');
-        parsoid._addSectionDivs(doc);
-        const sections = parsoid._getSectionsText(doc);
-        assert.deepEqual(sections.length, 1);
-        assert.deepEqual(sections[0].id, 0);
-        assert.deepEqual(sections[0].text, '');
-    });
-
-    it('getSectionsText() with just text should produce a lead section', () => 
{
-        const doc = domino.createDocument('<body>text0</body>');
-        parsoid._addSectionDivs(doc);
-        const sections = parsoid._getSectionsText(doc);
-        assert.deepEqual(sections.length, 1);
-        assertSection0(sections);
-    });
-
-    it('getSectionsText() with one h2 should produce two sections', () => {
-        const doc = domino.createDocument('<body>text0<h2 
id="foo">foo</h2>text1</body>');
-        parsoid._addSectionDivs(doc);
-        const sections = parsoid._getSectionsText(doc);
-        assert.deepEqual(sections.length, 2);
-        assertSection0(sections);
-        assertSection1(sections);
-    });
-
-    it('getSectionsText() with one h2 and h3 should produce three sections', 
() => {
-        const doc = domino.createDocument(html);
-        parsoid._addSectionDivs(doc);
-        const sections = parsoid._getSectionsText(doc);
-        assert.deepEqual(sections.length, 3);
-        assertSection0(sections);
-        assertSection1(sections);
-        assertSection2(sections);
-    });
 
     it('getBaseUri()', () => {
         const doc = domino.createDocument(headHtml1);
diff --git a/test/lib/parsoid/parsoid-sections-test.js 
b/test/lib/parsoid/parsoid-sections-test.js
new file mode 100644
index 0000000..0d9970e
--- /dev/null
+++ b/test/lib/parsoid/parsoid-sections-test.js
@@ -0,0 +1,73 @@
+'use strict';
+
+const assert = require('../../utils/assert.js');
+const domino = require('domino');
+const parsoid = require('../../../lib/parsoid-access');
+
+const html = '<body>text0' +
+    '<h2 id="foo">foo</h2>text1' +
+    '<h3 id="Funny_section_.21.40.23.24">Funny section !@#$%^&*()</h3>text2' +
+    '</body>';
+
+describe('lib:parsoid-sections', function() {
+
+    this.timeout(20000); // eslint-disable-line no-invalid-this
+
+    function assertSection0(sections) {
+        assert.deepEqual(sections[0].id, 0);
+        assert.deepEqual(sections[0].text, 'text0', 
JSON.stringify(sections[0], null, 2));
+    }
+
+    function assertSection1(sections) {
+        assert.deepEqual(sections[1].id, 1);
+        assert.deepEqual(sections[1].toclevel, 1);
+        assert.deepEqual(sections[1].line, 'foo');
+        assert.deepEqual(sections[1].anchor, 'foo');
+        assert.deepEqual(sections[1].text, 'text1');
+    }
+
+    function assertSection2(sections) {
+        assert.deepEqual(sections[2].id, 2);
+        assert.deepEqual(sections[2].toclevel, 2);
+        // assert.deepEqual(sections[2].line, 'Funny section !@#$');
+        assert.deepEqual(sections[2].anchor, 'Funny_section_.21.40.23.24');
+        assert.deepEqual(sections[2].text, 'text2');
+    }
+
+
+    it('getSectionsText(empty) should produce an empty lead section', () => {
+        const doc = domino.createDocument('<body></body>');
+        parsoid._addSectionDivs(doc);
+        const sections = parsoid._getSectionsText(doc);
+        assert.deepEqual(sections.length, 1);
+        assert.deepEqual(sections[0].id, 0);
+        assert.deepEqual(sections[0].text, '');
+    });
+
+    it('getSectionsText() with just text should produce a lead section', () => 
{
+        const doc = domino.createDocument('<body>text0</body>');
+        parsoid._addSectionDivs(doc);
+        const sections = parsoid._getSectionsText(doc);
+        assert.deepEqual(sections.length, 1);
+        assertSection0(sections);
+    });
+
+    it('getSectionsText() with one h2 should produce two sections', () => {
+        const doc = domino.createDocument('<body>text0<h2 
id="foo">foo</h2>text1</body>');
+        parsoid._addSectionDivs(doc);
+        const sections = parsoid._getSectionsText(doc);
+        assert.deepEqual(sections.length, 2);
+        assertSection0(sections);
+        assertSection1(sections);
+    });
+
+    it('getSectionsText() with one h2 and h3 should produce three sections', 
() => {
+        const doc = domino.createDocument(html);
+        parsoid._addSectionDivs(doc);
+        const sections = parsoid._getSectionsText(doc);
+        assert.deepEqual(sections.length, 3);
+        assertSection0(sections);
+        assertSection1(sections);
+        assertSection2(sections);
+    });
+});

-- 
To view, visit https://gerrit.wikimedia.org/r/372207
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9f86790b7275bb1be596a847490b7d79d7e72de1
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Dbrant <[email protected]>
Gerrit-Reviewer: Fjalapeno <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Mholloway <[email protected]>
Gerrit-Reviewer: Mhurd <[email protected]>
Gerrit-Reviewer: Mobrovac <[email protected]>
Gerrit-Reviewer: Ppchelko <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to