Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2752530
popupNotification.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
popupNotification.test.js
View Options
const
popUpNotification
=
require
(
'../../resources/skins.vector.js/popupNotification.js'
);
/**
* @type {string}
*/
let
testId
;
/**
* @type {string}
*/
let
testMessage
;
/**
* @type {string}
*/
let
vectorPopupClass
;
/**
* @type {Record<string,OoUiPopupWidget>}
*/
let
activeNotification
;
describe
(
'Popup Notification'
,
()
=>
{
beforeEach
(
()
=>
{
global
.
window
.
matchMedia
=
jest
.
fn
(
()
=>
(
{}
)
);
document
.
body
.
style
=
'direction: ltr'
;
jest
.
spyOn
(
mw
.
loader
,
'using'
)
.
mockImplementation
(
()
=>
Promise
.
resolve
()
);
testId
=
'test-id'
;
testMessage
=
'test message'
;
vectorPopupClass
=
'vector-popup-notification'
;
activeNotification
=
[];
popUpNotification
.
hideAll
();
}
);
afterEach
(
()
=>
{
jest
.
resetModules
();
}
);
// test add function
test
(
'add'
,
async
()
=>
{
const
popupWidget
=
await
popUpNotification
.
add
(
document
.
body
,
testMessage
,
testId
,
[],
4000
,
()
=>
{}
);
activeNotification
[
testId
]
=
popupWidget
;
expect
(
activeNotification
[
testId
]
).
toBeDefined
();
expect
(
activeNotification
[
testId
].
$element
).
toBeDefined
();
expect
(
activeNotification
[
testId
].
$element
[
0
].
textContent
)
.
toContain
(
testMessage
);
expect
(
activeNotification
[
testId
].
$element
[
0
].
classList
.
contains
(
vectorPopupClass
)
).
toBe
(
true
);
}
);
// test hide function
test
(
'hide'
,
async
()
=>
{
const
popupWidget
=
await
popUpNotification
.
add
(
document
.
body
,
testMessage
,
testId
,
[],
4000
,
()
=>
{}
);
activeNotification
[
testId
]
=
popupWidget
;
expect
(
activeNotification
[
testId
].
visible
).
toBe
(
false
);
popUpNotification
.
show
(
activeNotification
[
testId
]
);
expect
(
activeNotification
[
testId
].
visible
).
toBe
(
true
);
popUpNotification
.
hide
(
activeNotification
[
testId
]
);
expect
(
activeNotification
[
testId
].
visible
).
toBe
(
false
);
}
);
// test show function
test
(
'show'
,
async
()
=>
{
const
popupWidget
=
await
popUpNotification
.
add
(
document
.
body
,
testMessage
,
testId
,
[],
4000
,
()
=>
{}
);
activeNotification
[
testId
]
=
popupWidget
;
expect
(
activeNotification
[
testId
].
visible
).
toBe
(
false
);
popUpNotification
.
show
(
activeNotification
[
testId
]
);
expect
(
activeNotification
[
testId
].
visible
).
toBe
(
true
);
}
);
// test hideAll function
test
(
'hideAll'
,
async
()
=>
{
const
popupWidget
=
await
popUpNotification
.
add
(
document
.
body
,
testMessage
,
testId
,
[],
4000
,
()
=>
{}
);
activeNotification
[
testId
]
=
popupWidget
;
expect
(
activeNotification
[
testId
].
visible
).
toBe
(
false
);
popUpNotification
.
show
(
activeNotification
[
testId
]
);
expect
(
activeNotification
[
testId
].
visible
).
toBe
(
true
);
popUpNotification
.
hideAll
();
expect
(
activeNotification
[
testId
].
visible
).
toBe
(
false
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 3, 20:06 (1 d, 11 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
85/a6/0b89ae469bea10758a8d9839fc02
Default Alt Text
popupNotification.test.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment