2024-07-26 19:00:58 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
QUnit.module( 've.dm.MWDocumentReferences (Cite)', ve.test.utils.newMwEnvironment() );
|
|
|
|
|
|
|
|
QUnit.test( 'first simple test', ( assert ) => {
|
|
|
|
const doc = ve.dm.citeExample.createExampleDocument( 'references' );
|
|
|
|
const docRefs = ve.dm.MWDocumentReferences.static.refsForDoc( doc );
|
|
|
|
|
|
|
|
const mainNodes = docRefs.getGroupRefsByParents( 'mwReference/' );
|
|
|
|
const fooNodes = docRefs.getGroupRefsByParents( 'mwReference/foo' );
|
|
|
|
|
|
|
|
assert.strictEqual( mainNodes[ '' ].length, 4 );
|
|
|
|
assert.strictEqual( fooNodes[ '' ].length, 1 );
|
|
|
|
|
|
|
|
const firstListKey = mainNodes[ '' ][ 0 ].getAttribute( 'listKey' );
|
|
|
|
const fooGroupListKey = fooNodes[ '' ][ 0 ].getAttribute( 'listKey' );
|
|
|
|
|
|
|
|
assert.strictEqual( firstListKey, 'auto/0' );
|
|
|
|
assert.strictEqual( fooGroupListKey, 'auto/2' );
|
2024-07-27 17:04:33 +00:00
|
|
|
assert.strictEqual( docRefs.getIndexLabel( '', firstListKey ), '1' );
|
|
|
|
assert.strictEqual( docRefs.getIndexLabel( 'foo', fooGroupListKey ), '1' );
|
2024-07-26 19:00:58 +00:00
|
|
|
} );
|
2024-07-29 09:33:34 +00:00
|
|
|
|
|
|
|
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'.
|
2024-07-27 17:04:33 +00:00
|
|
|
assert.strictEqual( docRefs.getIndexLabel( '', firstListKey ), '1' );
|
2024-07-29 09:33:34 +00:00
|
|
|
|
|
|
|
const subrefListKey = groupedRefs[ 'literal/ldr' ][ 0 ].getAttribute( 'listKey' );
|
|
|
|
assert.strictEqual( subrefListKey, 'auto/0' );
|
|
|
|
// FIXME: Documents incorrect behavior, should be '1.1'.
|
2024-07-27 17:04:33 +00:00
|
|
|
assert.strictEqual( docRefs.getIndexLabel( '', subrefListKey ), '2.1' );
|
2024-07-29 09:33:34 +00:00
|
|
|
} );
|