mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-11 16:49:26 +00:00
Merge "Test MWDocumentReferences on subref doc"
This commit is contained in:
commit
014b0bcffb
|
@ -9,8 +9,6 @@ QUnit.test( 'first simple test', ( assert ) => {
|
|||
const mainNodes = docRefs.getGroupRefsByParents( 'mwReference/' );
|
||||
const fooNodes = docRefs.getGroupRefsByParents( 'mwReference/foo' );
|
||||
|
||||
assert.strictEqual( Object.keys( docRefs.getGroupRefsByParents() ).length, 0 );
|
||||
|
||||
assert.strictEqual( mainNodes[ '' ].length, 4 );
|
||||
assert.strictEqual( fooNodes[ '' ].length, 1 );
|
||||
|
||||
|
@ -22,3 +20,25 @@ QUnit.test( 'first simple test', ( assert ) => {
|
|||
assert.strictEqual( docRefs.getIndexNumber( '', firstListKey ), '1' );
|
||||
assert.strictEqual( docRefs.getIndexNumber( 'foo', fooGroupListKey ), '1' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'extends test', ( assert ) => {
|
||||
const doc = ve.dm.citeExample.createExampleDocument( 'extends' );
|
||||
const docRefs = ve.dm.MWDocumentReferences.static.refsForDoc( doc );
|
||||
|
||||
const groupedRefs = docRefs.getGroupRefsByParents( 'mwReference/' );
|
||||
|
||||
assert.strictEqual( Object.keys( groupedRefs ).length, 2 );
|
||||
|
||||
assert.strictEqual( groupedRefs[ '' ].length, 2 );
|
||||
assert.strictEqual( groupedRefs[ 'literal/ldr' ].length, 1 );
|
||||
|
||||
const firstListKey = groupedRefs[ '' ][ 0 ].getAttribute( 'listKey' );
|
||||
assert.strictEqual( firstListKey, 'auto/1' );
|
||||
// FIXME: Documents incorrect behavior, should be '2'.
|
||||
assert.strictEqual( docRefs.getIndexNumber( '', firstListKey ), '1' );
|
||||
|
||||
const subrefListKey = groupedRefs[ 'literal/ldr' ][ 0 ].getAttribute( 'listKey' );
|
||||
assert.strictEqual( subrefListKey, 'auto/0' );
|
||||
// FIXME: Documents incorrect behavior, should be '1.1'.
|
||||
assert.strictEqual( docRefs.getIndexNumber( '', subrefListKey ), '2.1' );
|
||||
} );
|
||||
|
|
|
@ -994,3 +994,54 @@ ve.dm.citeExample.complexInternalData.internalItems = [
|
|||
];
|
||||
|
||||
ve.dm.citeExample.complexInternalData.internalListNextUniqueNumber = 1;
|
||||
|
||||
ve.dm.citeExample.extends = [
|
||||
{ type: 'paragraph' },
|
||||
{ type: 'mwReference', attributes: {
|
||||
extendsRef: 'literal/ldr',
|
||||
listIndex: 0,
|
||||
listGroup: 'mwReference/',
|
||||
listKey: 'auto/0',
|
||||
refGroup: ''
|
||||
} },
|
||||
{ type: '/mwReference' },
|
||||
{ type: 'mwReference', attributes: {
|
||||
listIndex: 1,
|
||||
listGroup: 'mwReference/',
|
||||
listKey: 'auto/1',
|
||||
refGroup: ''
|
||||
} },
|
||||
{ type: '/mwReference' },
|
||||
{ type: '/paragraph' },
|
||||
{ type: 'mwReferencesList', attributes: {
|
||||
listGroup: 'mwReference/',
|
||||
refGroup: ''
|
||||
} },
|
||||
{ type: 'paragraph' },
|
||||
{ type: 'mwReference', attributes: {
|
||||
listIndex: 2,
|
||||
listGroup: 'mwReference/',
|
||||
listKey: 'literal/ldr',
|
||||
refGroup: ''
|
||||
} },
|
||||
{ type: '/mwReference' },
|
||||
{ type: '/paragraph' },
|
||||
{ type: '/mwReferencesList' },
|
||||
{ type: 'internalList' },
|
||||
{ type: 'internalItem' },
|
||||
{ type: 'paragraph' },
|
||||
'S', 'u', 'b', 'r', 'e', 'f',
|
||||
{ type: '/paragraph' },
|
||||
{ type: '/internalItem' },
|
||||
{ type: 'internalItem' },
|
||||
{ type: 'paragraph' },
|
||||
'O', 't', 'h', 'e', 'r',
|
||||
{ type: '/paragraph' },
|
||||
{ type: '/internalItem' },
|
||||
{ type: 'internalItem' },
|
||||
{ type: 'paragraph' },
|
||||
'L', 'i', 's', 't', '-', 'd', 'e', 'f', 'i', 'n', 'e', 'd',
|
||||
{ type: '/paragraph' },
|
||||
{ type: '/internalItem' },
|
||||
{ type: '/internalList' }
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue