mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-05 22:22:54 +00:00
edcaaf9edc
Add a static.name property to ce nodes and make sure both ce and dm nodes always use the static.name property in constructors and registration calls. The result of this is that any given node type should now only appear once in the code as a string. Bug: 45701 Change-Id: Ibf31de16ab28ad58209c1443cd74f93dda278998
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable NodeFactory tests.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
QUnit.module( 've.ce.NodeFactory' );
|
|
|
|
/* Stubs */
|
|
|
|
ve.ce.NodeFactoryNodeStub = function VeCeNodeFactoryNodeStub( a, b ) {
|
|
this.a = a;
|
|
this.b = b;
|
|
};
|
|
|
|
ve.inheritClass( ve.ce.NodeFactoryNodeStub, ve.ce.LeafNode );
|
|
|
|
ve.ce.NodeFactoryNodeStub.static.name = 'node-factory-node-stub';
|
|
|
|
/* Tests */
|
|
|
|
QUnit.test( 'canNodeBeSplit', 2, function ( assert ) {
|
|
var factory = new ve.ce.NodeFactory();
|
|
|
|
assert.throws( function () {
|
|
factory.canNodeBeSplit( 'node-factory-node-stub' );
|
|
},
|
|
Error,
|
|
'throws an exception when getting split rules for a node of an unregistered type'
|
|
);
|
|
factory.register( ve.ce.NodeFactoryNodeStub );
|
|
|
|
assert.strictEqual(
|
|
factory.canNodeBeSplit( 'node-factory-node-stub' ),
|
|
false,
|
|
'gets split rules for registered nodes'
|
|
);
|
|
} );
|
|
|
|
QUnit.test( 'initialization', 1, function ( assert ) {
|
|
assert.ok( ve.ce.nodeFactory instanceof ve.ce.NodeFactory, 'factory is initialized at ve.ce.nodeFactory' );
|
|
} );
|