Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4123680
mediawiki.api.parse.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.parse.test.js
View Options
QUnit
.
module
(
'mediawiki.api.edit'
,
(
hooks
)
=>
{
let
server
;
hooks
.
beforeEach
(
function
()
{
server
=
this
.
sandbox
.
useFakeServer
();
server
.
respondImmediately
=
true
;
}
);
QUnit
.
test
(
'.parse( string )'
,
async
(
assert
)
=>
{
server
.
respondWith
(
'POST'
,
/api.php/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{ "parse": { "text": "<p><b>Hello world</b></p>" } }'
]
);
const
html
=
await
new
mw
.
Api
().
parse
(
'\'\'\'Hello world\'\'\''
);
assert
.
strictEqual
(
html
,
'<p><b>Hello world</b></p>'
,
'Parse wikitext by string'
);
}
);
QUnit
.
test
(
'.parse( Object.toString )'
,
async
(
assert
)
=>
{
server
.
respondWith
(
'POST'
,
/api.php/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{ "parse": { "text": "<p><b>Hello world</b></p>" } }'
]
);
const
input
=
{
toString
:
function
()
{
return
'\'\'\'Hello world\'\'\''
;
}
};
const
html
=
await
new
mw
.
Api
().
parse
(
input
);
assert
.
strictEqual
(
html
,
'<p><b>Hello world</b></p>'
,
'Parse wikitext by toString object'
);
}
);
QUnit
.
test
(
'.parse( mw.Title )'
,
async
(
assert
)
=>
{
server
.
respondWith
(
'GET'
,
/action=parse.*&page=Earth/
,
[
200
,
{
'Content-Type'
:
'application/json'
},
'{ "parse": { "text": "<p><b>Earth</b> is a planet.</p>" } }'
]
);
const
html
=
await
new
mw
.
Api
().
parse
(
new
mw
.
Title
(
'Earth'
)
);
assert
.
strictEqual
(
html
,
'<p><b>Earth</b> is a planet.</p>'
,
'Parse page by Title object'
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 19, 06:17 (5 d, 23 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0e/0e/895ed99f60fae59f3c8bbf3d703d
Default Alt Text
mediawiki.api.parse.test.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment