Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4102542
mediawiki.api.messages.test.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
mediawiki.api.messages.test.js
View Options
QUnit
.
module
(
'mediawiki.api.messages'
,
(
hooks
)
=>
{
let
server
;
hooks
.
beforeEach
(
function
()
{
server
=
this
.
sandbox
.
useFakeServer
();
server
.
respondImmediately
=
true
;
}
);
QUnit
.
test
(
'.getMessages()'
,
async
(
assert
)
=>
{
server
.
respondWith
(
/ammessages=foo%7Cbaz/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{ "query": { "allmessages": ['
+
'{ "name": "foo", "content": "Foo bar" },'
+
'{ "name": "baz", "content": "Baz Quux" }'
+
'] } }'
]
);
assert
.
deepEqual
(
await
new
mw
.
Api
().
getMessages
(
[
'foo'
,
'baz'
]
),
{
foo
:
'Foo bar'
,
baz
:
'Baz Quux'
}
);
}
);
// Make sure we properly handle a string and don't try to slice it in the handling for
// multiple messages. The alphabet has 26 letters, so twice that is 52, if we don't
// switch the string to an array of one the slice() call would remove the last two letters
const
LONG_KEY
=
'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'
;
QUnit
.
test
(
'.getMessages() with a long string'
,
async
(
assert
)
=>
{
server
.
respondWith
(
new
RegExp
(
'ammessages='
+
LONG_KEY
),
[
200
,
{
'Content-Type'
:
'application/json'
},
'{ "query": { "allmessages": ['
+
'{ "name": "'
+
LONG_KEY
+
'", "content": "SomeRandomValue" }'
+
'] } }'
]
);
assert
.
deepEqual
(
await
new
mw
.
Api
().
getMessages
(
LONG_KEY
),
{
[
LONG_KEY
]
:
'SomeRandomValue'
}
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Aug 18, 17:30 (3 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
cc/2c/cc33ed124ef7f240665193fc8787
Default Alt Text
mediawiki.api.messages.test.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment