BearND has uploaded a new change for review. ( 
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, 73 insertions(+), 62 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/07/372207/1

diff --git a/test/lib/parsoid/parsoid-access-test.js 
b/test/lib/parsoid/parsoid-access-test.js
index b37e22f..5da708b 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/"/>
@@ -29,64 +25,6 @@
 describe('lib:parsoid', 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..9221dc7
--- /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/parsoidSections');
+
+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', 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: newchange
Gerrit-Change-Id: I9f86790b7275bb1be596a847490b7d79d7e72de1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND <[email protected]>

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

Reply via email to