Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4145716
IconButton.test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
IconButton.test.js
View Options
const
sinon
=
require
(
'sinon'
),
dom
=
require
(
'../utils/dom'
),
jQuery
=
require
(
'../utils/jQuery'
),
oo
=
require
(
'../utils/oo'
),
mediaWiki
=
require
(
'../utils/mw'
),
mustache
=
require
(
'../utils/mustache'
);
let
IconButton
,
sandbox
;
QUnit
.
module
(
'MobileFrontend IconButton.js'
,
{
beforeEach
:
function
()
{
sandbox
=
sinon
.
sandbox
.
create
();
dom
.
setUp
(
sandbox
,
global
);
jQuery
.
setUp
(
sandbox
,
global
);
oo
.
setUp
(
sandbox
,
global
);
mediaWiki
.
setUp
(
sandbox
,
global
);
mustache
.
setUp
(
sandbox
,
global
);
IconButton
=
require
(
'../../../src/mobile.startup/IconButton'
);
},
afterEach
:
function
()
{
jQuery
.
tearDown
();
sandbox
.
restore
();
}
}
);
QUnit
.
test
(
'creates a link if passed href option'
,
function
(
assert
)
{
const
url
=
'https://www.foo.com'
,
button
=
new
IconButton
(
{
href
:
url
}
);
assert
.
strictEqual
(
button
.
$el
[
0
].
tagName
,
'A'
);
assert
.
strictEqual
(
button
.
$el
[
0
].
getAttribute
(
'href'
),
url
);
}
);
QUnit
.
test
(
'does not add href attribute when not a link'
,
function
(
assert
)
{
const
button
=
new
IconButton
(
{
tagName
:
'div'
}
);
assert
.
strictEqual
(
button
.
$el
[
0
].
tagName
,
'DIV'
);
assert
.
strictEqual
(
button
.
$el
[
0
].
href
,
undefined
);
}
);
QUnit
.
test
(
'adds disabled attribute when a button'
,
function
(
assert
)
{
const
button
=
new
IconButton
(
{
tagName
:
'button'
,
disabled
:
true
}
);
assert
.
strictEqual
(
button
.
$el
[
0
].
tagName
,
'BUTTON'
);
assert
.
strictEqual
(
button
.
$el
[
0
].
disabled
,
true
);
}
);
QUnit
.
test
(
'does not add disabled attribute when not a button'
,
function
(
assert
)
{
const
button
=
new
IconButton
(
{
tagName
:
'div'
,
disabled
:
true
}
);
assert
.
strictEqual
(
button
.
$el
[
0
].
tagName
,
'DIV'
);
assert
.
strictEqual
(
button
.
$el
[
0
].
disabled
,
undefined
);
}
);
QUnit
.
test
(
'adds additional classes'
,
function
(
assert
)
{
const
button
=
new
IconButton
(
{
icon
:
'user'
,
additionalClassNames
:
'test'
}
);
assert
.
strictEqual
(
button
.
getButtonClasses
(),
'cdx-button cdx-button--size-large cdx-button--weight-quiet cdx-button--icon-only test'
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Aug 19 2026, 17:45 (5 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
86/ec/18ce939685b2d2cf099b8a3b7734
Default Alt Text
IconButton.test.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment