Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2750870
html.test.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
html.test.js
View Options
QUnit
.
module
(
'mediawiki.base/html'
,
()
=>
{
QUnit
.
test
(
'escape'
,
(
assert
)
=>
{
assert
.
throws
(
()
=>
{
mw
.
html
.
escape
();
},
TypeError
,
'throw a TypeError if argument is not a string'
);
assert
.
strictEqual
(
mw
.
html
.
escape
(
'<mw awesome="awesome" value=\'test\' />'
),
'<mw awesome="awesome" value='test' />'
,
'Escape special characters to html entities'
);
}
);
QUnit
.
test
(
'element()'
,
(
assert
)
=>
{
assert
.
strictEqual
(
mw
.
html
.
element
(),
'<undefined/>'
,
'return valid html even without arguments'
);
}
);
QUnit
.
test
(
'element( tagName )'
,
(
assert
)
=>
{
assert
.
strictEqual
(
mw
.
html
.
element
(
'div'
),
'<div/>'
,
'DIV'
);
}
);
QUnit
.
test
(
'element( tagName, attrs )'
,
(
assert
)
=>
{
assert
.
strictEqual
(
mw
.
html
.
element
(
'div'
,
{}
),
'<div/>'
,
'DIV'
);
assert
.
strictEqual
(
mw
.
html
.
element
(
'div'
,
{
id
:
'foobar'
}
),
'<div id="foobar"/>'
,
'DIV with attribs'
);
}
);
QUnit
.
test
(
'element( tagName, attrs, content )'
,
(
assert
)
=>
{
assert
.
strictEqual
(
mw
.
html
.
element
(
'div'
,
{},
''
),
'<div></div>'
,
'DIV with empty attributes and content'
);
assert
.
strictEqual
(
mw
.
html
.
element
(
'p'
,
{},
12
),
'<p>12</p>'
,
'numbers as content cast to strings'
);
assert
.
strictEqual
(
mw
.
html
.
element
(
'p'
,
{
title
:
12
},
''
),
'<p title="12"></p>'
,
'number as attribute value'
);
assert
.
strictEqual
(
mw
.
html
.
element
(
'div'
,
{},
new
mw
.
html
.
Raw
(
mw
.
html
.
element
(
'img'
,
{
src
:
'<'
}
)
)
),
'<div><img src="<"/></div>'
,
'unescaped content with mw.html.Raw'
);
assert
.
strictEqual
(
mw
.
html
.
element
(
'option'
,
{
selected
:
true
},
'Foo'
),
'<option selected="selected">Foo</option>'
,
'boolean true attribute value'
);
assert
.
strictEqual
(
mw
.
html
.
element
(
'option'
,
{
value
:
'foo'
,
selected
:
false
},
'Foo'
),
'<option value="foo">Foo</option>'
,
'boolean false attribute value'
);
assert
.
strictEqual
(
mw
.
html
.
element
(
'div'
,
null
,
'a'
),
'<div>a</div>'
,
'Skip attributes with null'
);
assert
.
strictEqual
(
mw
.
html
.
element
(
'a'
,
{
href
:
'http://mediawiki.org/w/index.php?title=RL&action=history'
},
'a'
),
'<a href="http://mediawiki.org/w/index.php?title=RL&action=history">a</a>'
,
'Andhor tag with attributes and content'
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/html
Expires
Fri, Jul 3, 17:17 (20 h, 13 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
32/1a/f68325932ef44b7f8bb4d110a70a
Default Alt Text
html.test.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment