mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Tests for some trivial but critical template model methods
Not only do we want to make sure getUniquePartId() always starts at 0 and increments correctly, it should return a number (and not e.g. "part_0"). I realize the getTitle() test is also testing functionality from mw.libs.ve.… (can be found in the file ve.utils.parsoid.js). This is intentional. What we care about at this point is not a library but the very specific functionality of a very specific method we use quite a lot in code we touch. Bug: T289560 Change-Id: I43c1d00dacf27a68b16f62ecca4adda22f437391
This commit is contained in:
parent
e778057389
commit
55beccbb79
|
@ -36,6 +36,19 @@
|
|||
|
||||
/* Tests */
|
||||
|
||||
[
|
||||
[ undefined, null ],
|
||||
[ '', null ],
|
||||
[ 'no_prefix', 'no prefix' ],
|
||||
[ '/unexpected_prefix', '/unexpected prefix' ],
|
||||
[ './Template:%C3%9Cnicode%5Fexample/subpage', 'Template:Ünicode example/subpage' ],
|
||||
[ './Template:Possibly_invalid%5B%5D', 'Template:Possibly invalid[]' ]
|
||||
].forEach( ( [ href, expected ] ) => QUnit.test( 'getTitle: ' + href, ( assert ) => {
|
||||
const transclusion = { getUniquePartId: () => 0 },
|
||||
template = new ve.dm.MWTemplateModel( transclusion, { href } );
|
||||
assert.strictEqual( template.getTitle(), expected );
|
||||
} ) );
|
||||
|
||||
QUnit.test( 'hasParameter', ( assert ) => {
|
||||
const template = newTemplateModel();
|
||||
|
||||
|
|
|
@ -35,6 +35,13 @@
|
|||
} );
|
||||
}
|
||||
|
||||
QUnit.test( 'getUniquePartId', function ( assert ) {
|
||||
const transclusion = new ve.dm.MWTransclusionModel();
|
||||
assert.strictEqual( transclusion.getUniquePartId(), 0 );
|
||||
assert.strictEqual( transclusion.getUniquePartId(), 1 );
|
||||
assert.strictEqual( transclusion.getUniquePartId(), 2 );
|
||||
} );
|
||||
|
||||
QUnit.test( 'fetch template part data', function ( assert ) {
|
||||
const response = {
|
||||
batchcomplete: '',
|
||||
|
|
Loading…
Reference in a new issue