2014-06-27 23:07:33 -07:00
|
|
|
QUnit.test('Simple', function(assert) {
|
|
|
|
|
assert.expect(1);
|
2014-06-27 23:54:22 -07:00
|
|
|
var context = new rr.Context(mediawiki,
|
|
|
|
|
'=== Heading ===\n' +
|
|
|
|
|
'This is a wiki doc.\n' +
|
2014-06-28 17:30:21 -07:00
|
|
|
"How about some '''bold and ''bold italic'''''.\n" +
|
2014-06-27 23:54:22 -07:00
|
|
|
'I would also love some <nowiki>nowiki <b>foo</b></nowiki>');
|
2014-06-26 22:48:03 -07:00
|
|
|
var iterable = context.rules['wikidoc'].match(context);
|
2014-06-27 23:07:33 -07:00
|
|
|
assert.equal(iterable.next().value.nodes[0].innerHTML,
|
2014-06-27 23:54:22 -07:00
|
|
|
'<h3>Heading</h3>This is a wiki doc.\n' +
|
2014-06-29 17:39:24 -07:00
|
|
|
"How about some <b>bold and ''bold italic</b>''.\n" +
|
2014-06-27 23:54:22 -07:00
|
|
|
'I would also love some nowiki <b>foo</b>');
|
2014-05-20 12:49:30 -07:00
|
|
|
});
|
2014-06-28 22:23:54 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
QUnit.test('ZeroOrMore', function(assert) {
|
|
|
|
|
assert.expect(1);
|
|
|
|
|
var rules = {
|
2014-06-29 17:39:24 -07:00
|
|
|
'test': rr.Node('test',
|
|
|
|
|
rr.Sequence(rr.ZeroOrMore(rr.MultiLineText()), rr.EndOfText()))
|
2014-06-28 22:23:54 -07:00
|
|
|
};
|
|
|
|
|
var context = new rr.Context(rules, 'foobar');
|
|
|
|
|
var iterable = context.rules['test'].match(context);
|
|
|
|
|
assert.equal(iterable.next().value.nodes[0].outerHTML,
|
|
|
|
|
'<test>foobar</test>');
|
|
|
|
|
});
|