Cscott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/50046
Change subject: Fix up Jasmine tests; remove HTML5 dependency.
......................................................................
Fix up Jasmine tests; remove HTML5 dependency.
The Jasmine tests currently all fail, apparently due largely to a
change in how <nowiki> is processed -- but at least they run now.
Looks like they've been neglected for a while; probably broken since
at least dfcd5a21d1a312b841df4575a175bb7959cc8cff on Jan 14 2013.
Change-Id: I0383917444d054416bf1aaabf7fae470361133a2
---
M js/tests/package.json
M js/tests/parsoid.js
M js/tests/specs.js
M js/tests/specs/html2wt.spec.js
4 files changed, 18 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/46/50046/1
diff --git a/js/tests/package.json b/js/tests/package.json
index 361c8c6..09dd6c8 100644
--- a/js/tests/package.json
+++ b/js/tests/package.json
@@ -3,8 +3,8 @@
"description": "Jasmine test for Parsoid",
"version": "0.0.1",
"dependencies": {
- "html5": "0.x.x",
- "jasmine-node": "1.x.x",
+ "domino": "~1.0.8",
+ "jasmine-node": "~1.2.3",
"should": "x.x.x"
}
}
diff --git a/js/tests/parsoid.js b/js/tests/parsoid.js
index 7ace88e..a3b3b54 100644
--- a/js/tests/parsoid.js
+++ b/js/tests/parsoid.js
@@ -1,4 +1,4 @@
-var HTML5 = require('html5').HTML5;
+var domino = require('domino');
// No instance properties
function Parsoid() {}
@@ -6,7 +6,7 @@
function initParsoid() {
var path = require('path');
var fileDependencies = [];
- var basePath = path.join(path.dirname(path.dirname(process.cwd())),
'js');
+ var basePath = '..';
function _require(filename) {
var fullpath = path.join( basePath, filename );
@@ -22,6 +22,7 @@
}
_import(path.join('lib', 'mediawiki.parser.environment.js'),
['MWParserEnvironment']);
+ _import(path.join('lib', 'mediawiki.ParsoidConfig.js'),
['ParsoidConfig']);
_import(path.join('lib', 'mediawiki.parser.js'),
['ParserPipelineFactory']);
_import(path.join('lib', 'mediawiki.WikitextSerializer.js'),
['WikitextSerializer']);
@@ -32,13 +33,15 @@
};
var parsoidConfig = new ParsoidConfig( null, options );
- MWParserEnvironment.getParserEnv( parsoidConfig, null, null, function (
err, mwEnv ) {
+ MWParserEnvironment.getParserEnv( parsoidConfig, null, null, null,
function ( err, mwEnv ) {
if ( err !== null ) {
console.error( err.toString() );
process.exit( 1 );
}
// "class" properties
- Parsoid.html5 = new HTML5.Parser();
+ Parsoid.createDocument = function(html) {
+ return domino.createDocument(html);
+ };
Parsoid.serializer = new WikitextSerializer({env: mwEnv});
} );
}
diff --git a/js/tests/specs.js b/js/tests/specs.js
index 594bd8a..d6c3255 100644
--- a/js/tests/specs.js
+++ b/js/tests/specs.js
@@ -18,6 +18,11 @@
}
});
-jasmine.executeSpecsInFolder(__dirname + '/specs', function(runner, log){
+jasmine.executeSpecsInFolder({
+ specFolder:__dirname + '/specs',
+ onComplete: function(runner, log) {
process.exit(runner.results().failedCount);
-}, isVerbose, showColors);
+ },
+ isVerbose: isVerbose,
+ showColors: showColors
+});
diff --git a/js/tests/specs/html2wt.spec.js b/js/tests/specs/html2wt.spec.js
index 836cb70..29b28cb 100644
--- a/js/tests/specs/html2wt.spec.js
+++ b/js/tests/specs/html2wt.spec.js
@@ -3,8 +3,8 @@
// Helpers
function dom(snippet) {
- parsoid.html5.parse( '<html><body>' + snippet + '</body></html>');
- return parsoid.html5.tree.document.childNodes[0].childNodes[1];
+ var document = parsoid.createDocument('<html><body>' + snippet +
'</body></html>');
+ return document.body;
}
function wikitext(dom) {
--
To view, visit https://gerrit.wikimedia.org/r/50046
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0383917444d054416bf1aaabf7fae470361133a2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits