2 QUnit
.module( 'mediawiki.html' );
4 QUnit
.test( 'escape', 2, function ( assert
) {
10 'throw a TypeError if argument is not a string'
14 mw
.html
.escape( '<mw awesome="awesome" value=\'test\' />' ),
15 '<mw awesome="awesome" value='test' />',
16 'Escape special characters to html entities'
20 QUnit
.test( 'element()', 1, function ( assert
) {
24 'return valid html even without arguments'
28 QUnit
.test( 'element( tagName )', 1, function ( assert
) {
29 assert
.equal( mw
.html
.element( 'div' ), '<div/>', 'DIV' );
32 QUnit
.test( 'element( tagName, attrs )', 2, function ( assert
) {
33 assert
.equal( mw
.html
.element( 'div', {} ), '<div/>', 'DIV' );
46 QUnit
.test( 'element( tagName, attrs, content )', 8, function ( assert
) {
48 assert
.equal( mw
.html
.element( 'div', {}, '' ), '<div></div>', 'DIV with empty attributes and content' );
50 assert
.equal( mw
.html
.element( 'p', {}, 12 ), '<p>12</p>', 'numbers as content cast to strings' );
52 assert
.equal( mw
.html
.element( 'p', { title
: 12 }, '' ), '<p title="12"></p>', 'number as attribute value' );
59 mw
.html
.element( 'img', { src
: '<' } )
62 '<div><img src="<"/></div>',
63 'unescaped content with mw.html.Raw'
74 '<option selected="selected">Foo</option>',
75 'boolean true attribute value'
87 '<option value="foo">Foo</option>',
88 'boolean false attribute value'
92 mw
.html
.element( 'div', null, 'a' ),
94 'Skip attributes with null' );
97 mw
.html
.element( 'a', {
98 href
: 'http://mediawiki.org/w/index.php?title=RL&action=history'
100 '<a href="http://mediawiki.org/w/index.php?title=RL&action=history">a</a>',
101 'Andhor tag with attributes and content'