Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2751200
SearchOverlay.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
SearchOverlay.test.js
View Options
let
SearchOverlay
,
SearchGateway
,
onBeforeExitSpy
,
sandbox
,
api
,
overlayOptions
;
const
jQuery
=
require
(
'../../utils/jQuery'
),
dom
=
require
(
'../../utils/dom'
),
oo
=
require
(
'../../utils/oo'
),
mediaWiki
=
require
(
'../../utils/mw'
),
mustache
=
require
(
'../../utils/mustache'
),
sinon
=
require
(
'sinon'
);
QUnit
.
module
(
'MobileFrontend mobile.startup/SearchOverlay.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
);
api
=
new
mw
.
Api
();
sandbox
.
stub
(
global
.
window
,
'scrollTo'
).
callsFake
(
()
=>
{}
);
SearchGateway
=
require
(
'../../../../src/mobile.startup/search/SearchGateway'
);
onBeforeExitSpy
=
sandbox
.
spy
();
SearchOverlay
=
require
(
'../../../../src/mobile.startup/search/SearchOverlay'
);
overlayOptions
=
{
placeholderMsg
:
'Search for bananas'
,
api
,
onBeforeExit
:
onBeforeExitSpy
,
gateway
:
new
SearchGateway
(
api
)
};
},
afterEach
:
function
()
{
jQuery
.
tearDown
();
sandbox
.
restore
();
}
}
);
QUnit
.
test
(
'renders correctly'
,
function
(
assert
)
{
const
overlay
=
new
SearchOverlay
(
overlayOptions
);
assert
.
strictEqual
(
overlay
.
$el
.
find
(
'.overlay-title'
).
length
,
1
,
'It contains an overlay title'
);
assert
.
strictEqual
(
overlay
.
$el
.
find
(
'.search-results-view'
).
length
,
1
,
'It contains a SearchResultsView'
);
assert
.
strictEqual
(
overlay
.
$el
.
find
(
'.results-list-container'
).
length
,
1
,
'Contains search results container'
);
}
);
QUnit
.
test
(
'resetSearch'
,
function
(
assert
)
{
const
overlay
=
new
SearchOverlay
(
overlayOptions
);
overlay
.
resetSearch
();
assert
.
strictEqual
(
overlay
.
$el
.
find
(
'.search-results-view'
).
is
(
'visible'
),
false
,
'All children are now hidden'
);
}
);
QUnit
.
test
(
'onClickOverlayContent'
,
function
(
assert
)
{
const
overlay
=
new
SearchOverlay
(
overlayOptions
);
overlay
.
onClickOverlayContent
();
assert
.
strictEqual
(
onBeforeExitSpy
.
called
,
true
,
'Click handler triggers close of overlay'
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 3, 18:03 (1 d, 5 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4b/db/d4262eb94fcb40e462df4370dba9
Default Alt Text
SearchOverlay.test.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment