Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4116946
portlets.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
portlets.test.js
View Options
const
portlets
=
require
(
'../../../resources/skins.vector.js/portlets.js'
);
const
mustache
=
require
(
'mustache'
);
const
fs
=
require
(
'fs'
);
const
menuTemplate
=
fs
.
readFileSync
(
'includes/templates/Menu.mustache'
,
'utf8'
);
const
menuContentsTemplate
=
fs
.
readFileSync
(
'includes/templates/MenuContents.mustache'
,
'utf8'
);
const
dropdownOpen
=
fs
.
readFileSync
(
'includes/templates/Dropdown/Open.mustache'
,
'utf8'
);
const
dropdownClose
=
fs
.
readFileSync
(
'includes/templates/Dropdown/Close.mustache'
,
'utf8'
);
describe
(
'portlets'
,
()
=>
{
beforeEach
(
()
=>
{
const
marker
=
document
.
querySelector
(
'#vector-page-tools-dropdown'
);
if
(
marker
)
{
marker
.
remove
();
}
}
);
test
(
'portlets that go through the hook method should match the menu template HTML'
,
()
=>
{
const
id
=
'foo'
;
const
label
=
'label text'
;
const
portletHTML
=
mustache
.
render
(
menuTemplate
,
{
id
,
class
:
''
,
label
},
{
MenuContents
:
menuContentsTemplate
}
);
const
element
=
document
.
createElement
(
'div'
);
element
.
id
=
id
;
const
labelElement
=
document
.
createElement
(
'label'
);
labelElement
.
textContent
=
label
;
element
.
appendChild
(
labelElement
);
element
.
appendChild
(
document
.
createElement
(
'ul'
)
);
expect
(
portlets
.
addPortletHandler
(
element
).
outerHTML
.
replace
(
/[\s\n]/gi
,
''
)
)
.
toBe
(
portletHTML
.
replace
(
/[\s\n]/gi
,
''
)
);
}
);
test
(
'portlets that go through the hook method should match the menu template HTML (dropdowns)'
,
()
=>
{
const
id
=
'foo'
;
const
label
=
'dropdown label text'
;
const
marker
=
document
.
createElement
(
'div'
);
marker
.
id
=
'vector-page-tools-dropdown'
;
document
.
body
.
appendChild
(
marker
);
const
dropdownHTML
=
mustache
.
render
(
dropdownOpen
,
{
id
:
`
${
id
}
-dropdown`
,
class
:
'foo-dropdown'
,
label
},
{}
)
+
mustache
.
render
(
dropdownClose
,
{},
{}
);
const
element
=
document
.
createElement
(
'div'
);
element
.
id
=
id
;
const
labelElement
=
document
.
createElement
(
'label'
);
labelElement
.
textContent
=
label
;
element
.
appendChild
(
labelElement
);
element
.
appendChild
(
document
.
createElement
(
'ul'
)
);
document
.
body
.
appendChild
(
element
);
const
transformedPortlet
=
portlets
.
addPortletHandler
(
element
,
'#p-cactions'
);
const
dropdown
=
transformedPortlet
.
closest
(
'.vector-dropdown'
);
// removing the portlet should give us an empty dropdown
transformedPortlet
.
remove
();
expect
(
dropdown
.
outerHTML
.
replace
(
/[\s\n]/gi
,
''
)
)
.
toBe
(
dropdownHTML
.
replace
(
/[\s\n]/gi
,
''
)
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 19, 01:56 (2 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b2/32/fd05053c57b05209fec368e71ebc
Default Alt Text
portlets.test.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment