Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4106832
mediawiki.api.category.test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
mediawiki.api.category.test.js
View Options
QUnit
.
module
(
'mediawiki.api.category'
,
(
hooks
)
=>
{
let
server
;
hooks
.
beforeEach
(
function
()
{
server
=
this
.
sandbox
.
useFakeServer
();
server
.
respondImmediately
=
true
;
}
);
QUnit
.
test
(
'.getCategoriesByPrefix()'
,
async
(
assert
)
=>
{
server
.
respondWith
(
[
200
,
{
'Content-Type'
:
'application/json'
},
'{ "query": { "allpages": [ '
+
'{ "title": "Category:Food" },'
+
'{ "title": "Category:Fool Supermarine S.6" },'
+
'{ "title": "Category:Fools" }'
+
'] } }'
]
);
const
matches
=
await
new
mw
.
Api
().
getCategoriesByPrefix
(
'Foo'
);
assert
.
deepEqual
(
matches
,
[
'Food'
,
'Fool Supermarine S.6'
,
'Fools'
]
);
}
);
QUnit
.
test
(
'.isCategory("")'
,
async
(
assert
)
=>
{
server
.
respondWith
(
/titles=$/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{"batchcomplete":true}'
]
);
const
response
=
await
new
mw
.
Api
().
isCategory
(
''
);
assert
.
strictEqual
(
response
,
false
);
}
);
QUnit
.
test
(
'.isCategory("#")'
,
async
(
assert
)
=>
{
server
.
respondWith
(
/titles=%23$/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{"batchcomplete":true,"query":{"normalized":[{"fromencoded":false,"from":"#","to":""}]}}'
]
);
const
response
=
await
new
mw
.
Api
().
isCategory
(
'#'
);
assert
.
strictEqual
(
response
,
false
);
}
);
QUnit
.
test
(
'.isCategory("mw:")'
,
async
(
assert
)
=>
{
server
.
respondWith
(
/titles=mw%3A$/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{"batchcomplete":true,"query":{"interwiki":[{"title":"mw:","iw":"mw"}]}}'
]
);
const
response
=
await
new
mw
.
Api
().
isCategory
(
'mw:'
);
assert
.
strictEqual
(
response
,
false
);
}
);
QUnit
.
test
(
'.isCategory("|")'
,
async
(
assert
)
=>
{
server
.
respondWith
(
/titles=%1F%7C$/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{"batchcomplete":true,"query":{"pages":[{"title":"|","invalidreason":"The requested page title contains invalid characters: \\"|\\".","invalid":true}]}}'
]
);
const
response
=
await
new
mw
.
Api
().
isCategory
(
'|'
);
assert
.
strictEqual
(
response
,
false
);
}
);
QUnit
.
test
(
'.getCategories("")'
,
async
(
assert
)
=>
{
server
.
respondWith
(
/titles=$/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{"batchcomplete":true}'
]
);
const
response
=
await
new
mw
.
Api
().
getCategories
(
''
);
assert
.
strictEqual
(
response
,
false
);
}
);
QUnit
.
test
(
'.getCategories("#")'
,
async
(
assert
)
=>
{
server
.
respondWith
(
/titles=%23$/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{"batchcomplete":true,"query":{"normalized":[{"fromencoded":false,"from":"#","to":""}]}}'
]
);
const
response
=
await
new
mw
.
Api
().
getCategories
(
'#'
);
assert
.
strictEqual
(
response
,
false
);
}
);
QUnit
.
test
(
'.getCategories("mw:")'
,
async
(
assert
)
=>
{
server
.
respondWith
(
/titles=mw%3A$/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{"batchcomplete":true,"query":{"interwiki":[{"title":"mw:","iw":"mw"}]}}'
]
);
const
response
=
await
new
mw
.
Api
().
getCategories
(
'mw:'
);
assert
.
strictEqual
(
response
,
false
);
}
);
QUnit
.
test
(
'.getCategories("|")'
,
async
(
assert
)
=>
{
server
.
respondWith
(
/titles=%1F%7C$/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{"batchcomplete":true,"query":{"pages":[{"title":"|","invalidreason":"The requested page title contains invalid characters: \\"|\\".","invalid":true}]}}'
]
);
const
response
=
await
new
mw
.
Api
().
getCategories
(
'|'
);
assert
.
strictEqual
(
response
,
false
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Aug 18, 19:45 (2 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1b/e3/200ec523ae32e628c28db258ecc8
Default Alt Text
mediawiki.api.category.test.js (3 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment