Debian Codegraph @

extensions/VisualEditor/lib/ve/tests/dm/ve.dm.LeafNode.test.js

raw symbols SCIP
1 /*!
2 * VisualEditor DataModel LeafNode tests.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 QUnit.module( 've.dm.LeafNode' );
8
9 /* Stubs */
10
11 ve.dm.LeafNodeStub = function VeDmLeafNodeStub() {
12 // Parent constructor
13 ve.dm.LeafNodeStub.super.apply( this, arguments );
14 };
15
16 OO.inheritClass( ve.dm.LeafNodeStub, ve.dm.LeafNode );
17
18 ve.dm.LeafNodeStub.static.name = 'leaf-stub';
19
20 ve.dm.LeafNodeStub.static.matchTagNames = [];
21
22 ve.dm.nodeFactory.register( ve.dm.LeafNodeStub );
23
24 /* Tests */
25
26 QUnit.test( 'canHaveChildren', ( assert ) => {
27 const node = new ve.dm.LeafNodeStub();
28 assert.strictEqual( node.canHaveChildren(), false );
29 } );
30
31 QUnit.test( 'canHaveChildrenNotContent', ( assert ) => {
32 const node = new ve.dm.LeafNodeStub();
33 assert.strictEqual( node.canHaveChildrenNotContent(), false );
34 } );
35
36 QUnit.test( 'getAnnotations', ( assert ) => {
37 const element = { type: 'leaf-stub' },
38 node = new ve.dm.LeafNodeStub( element );
39 assert.deepEqual( node.getAnnotations(), [], 'undefined .annotations returns empty set' );
40 assert.strictEqual( element.annotations, undefined, 'no .annotations property added' );
41 element.annotations = [ 0 ];
42 assert.deepEqual( node.getAnnotations(), [ 0 ], 'annotations retrieve indexes when set' );
43 } );