mediawiki-extensions-Visual.../modules/parser/test/expansionTest.js
Carl Fürstenberg dca609e3f9 Parsoid: move tests/parser to modules/parser/test
In preparation for the big extraction of Parsoid out of VisualEditor,
we'll start by moving the tests into the parsoid location.

Change-Id: I4a926ee4aad1490d4f769d44e91af80842b881f0
2012-07-25 02:29:25 +02:00

88 lines
1.3 KiB
JavaScript

var pageDatabase = {
'Boring': 'Just some text and [[a link]].',
'Template:Parens': '({{{1}}})',
'ParenCaller': '{{Parens|bizbax}}'
}
var domDatabase = {
'Boring': {
type: 'root',
contents: [
'Just some text and ',
{
type: 'link',
target: 'a link'
},
'.'
]
},
'Template:Parens': {
type: 'root',
contents: [
'(',
{
type: 'tplarg',
/*
contents: [
'1'
]*/
name: '1'
},
')'
]
},
'ParenCaller': {
type: 'root',
contents: [
{
type: 'template',
/*
contents: [
{
type: 'title',
contents: [
'Parens'
]
},
{
type: 'part',
contents: [
{
type: 'name',
index: 1
},
{
type: 'value',
contents: [
'bizbax'
]
}
]
}
]*/
name: 'Parens',
params: {
1: 'bizbax'
}
}
]
}
};
$(function() {
var env = new MWParserEnvironment({
'pageCache': pageDatabase,
'domCache': domDatabase
});
env.debug = true;
var frame = new PPFrame(env);
//var victim = 'Boring';
var victim = 'ParenCaller';
frame.expand(domDatabase[victim], 0, function(node, err) {
if (err) {
console.log('error', err);
} else {
console.log(node);
}
});
})