Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4055565
ext.centralNotice.geoIP.tests.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ext.centralNotice.geoIP.tests.js
View Options
(
function
()
{
'use strict'
;
const
COOKIE_NAME
=
'GeoIP'
,
BAD_COOKIE
=
'asdfasdf'
,
UNKNOWN_COOKIE
=
':::::v4'
,
GOOD_COOKIE
=
'US:CO:Denver:39.6762:-104.887:v4'
,
GOOD_GEO
=
{
af
:
'v4'
,
city
:
'Denver'
,
country
:
'US'
,
lat
:
39.6762
,
lon
:
-
104.887
,
region
:
'CO'
},
realCookie
=
$
.
cookie
(
COOKIE_NAME
);
QUnit
.
module
(
'ext.centralNotice.geoIP'
,
QUnit
.
newMwEnvironment
(
{
afterEach
:
function
()
{
// This cookie is always set to '/' in prod and should be here too.
// If a cookie of the same name is set without a path it may be
// found first by the jquery getter and will screw some behaviors
// up until it is removed.
$
.
cookie
(
COOKIE_NAME
,
realCookie
,
{
path
:
'/'
}
);
}
}
)
);
QUnit
.
test
(
'parse geo from valid cookie'
,
(
assert
)
=>
{
$
.
cookie
(
COOKIE_NAME
,
GOOD_COOKIE
,
{
path
:
'/'
}
);
mw
.
geoIP
.
makeGeoWithPromise
();
return
mw
.
geoIP
.
getPromise
().
then
(
(
geo
)
=>
{
assert
.
deepEqual
(
geo
,
GOOD_GEO
,
'parsed geo'
);
},
// Message to show when promise fails
()
=>
'geo not retrieved'
);
}
);
QUnit
.
test
(
'cookie invalid'
,
(
assert
)
=>
{
$
.
cookie
(
COOKIE_NAME
,
BAD_COOKIE
,
{
path
:
'/'
}
);
// Make sure that we don't fall back
mw
.
config
.
set
(
'wgCentralNoticeGeoIPBackgroundLookupModule'
,
false
);
mw
.
geoIP
.
makeGeoWithPromise
();
mw
.
geoIP
.
getPromise
().
fail
(
()
=>
{
assert
.
true
(
true
,
'geoIP promise fails, as expected'
);
}
).
done
(
()
=>
{
assert
.
true
(
false
,
'geoIP promise succeeded, but should not have'
);
}
);
}
);
QUnit
.
test
(
'cookie valid but unknown location'
,
(
assert
)
=>
{
$
.
cookie
(
COOKIE_NAME
,
UNKNOWN_COOKIE
,
{
path
:
'/'
}
);
// Make sure that we don't fall back
mw
.
config
.
set
(
'wgCentralNoticeGeoIPBackgroundLookupModule'
,
false
);
mw
.
geoIP
.
makeGeoWithPromise
();
mw
.
geoIP
.
getPromise
().
fail
(
()
=>
{
assert
.
true
(
true
,
'geoIP promise fails, as expected'
);
}
).
done
(
()
=>
{
assert
.
true
(
false
,
'geoIP promise succeeded, but should not have'
);
}
);
}
);
}()
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Aug 16 2026, 01:09 (12 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1f/a5/c82ae6a4a8a9a307350b52b7761c
Default Alt Text
ext.centralNotice.geoIP.tests.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment