mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
76bac7d152
Change-Id: Id0a0bd5b4a91f702cad34e9f5e7f2121763abffd
42 lines
1 KiB
JavaScript
42 lines
1 KiB
JavaScript
/**
|
|
* VisualEditor content editable NodeFactory tests.
|
|
*
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
module( 've.ce.NodeFactory' );
|
|
|
|
/* Stubs */
|
|
|
|
ve.ce.NodeFactoryNodeStub = function( a, b ) {
|
|
this.a = a;
|
|
this.b = b;
|
|
};
|
|
|
|
ve.ce.NodeFactoryNodeStub.rules = {
|
|
'canBeSplit': false
|
|
};
|
|
|
|
/* Tests */
|
|
|
|
test( 'canNodeBeSplit', 2, function( assert ) {
|
|
var factory = new ve.ce.NodeFactory();
|
|
assert.throws( function() {
|
|
factory.canNodeBeSplit( 'node-factory-node-stub' );
|
|
},
|
|
/^Unknown node type: node-factory-node-stub$/,
|
|
'throws an exception when getting split rules for a node of an unregistered type'
|
|
);
|
|
factory.register( 'node-factory-node-stub', ve.ce.NodeFactoryNodeStub );
|
|
assert.strictEqual(
|
|
factory.canNodeBeSplit( 'node-factory-node-stub' ),
|
|
false,
|
|
'gets split rules for registered nodes'
|
|
);
|
|
} );
|
|
|
|
test( 'initialization', 1, function( assert ) {
|
|
assert.ok( ve.ce.nodeFactory instanceof ve.ce.NodeFactory, 'factory is initialized at ve.ce.nodeFactory' );
|
|
} );
|