2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor content editable NodeFactory tests.
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2012-07-19 00:11:26 +00:00
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2012-04-30 23:36:02 +00:00
|
|
|
module( 've.ce.NodeFactory' );
|
|
|
|
|
|
|
|
/* Stubs */
|
|
|
|
|
|
|
|
ve.ce.NodeFactoryNodeStub = function( a, b ) {
|
|
|
|
this.a = a;
|
|
|
|
this.b = b;
|
|
|
|
};
|
|
|
|
|
|
|
|
ve.ce.NodeFactoryNodeStub.rules = {
|
|
|
|
'canBeSplit': false
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
2012-07-10 19:46:08 +00:00
|
|
|
test( 'canNodeBeSplit', 2, function( assert ) {
|
2012-04-30 23:36:02 +00:00
|
|
|
var factory = new ve.ce.NodeFactory();
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.throws( function() {
|
2012-05-31 23:50:16 +00:00
|
|
|
factory.canNodeBeSplit( 'node-factory-node-stub' );
|
2012-04-30 23:36:02 +00:00
|
|
|
},
|
2012-05-22 00:39:03 +00:00
|
|
|
/^Unknown node type: node-factory-node-stub$/,
|
2012-05-31 23:50:16 +00:00
|
|
|
'throws an exception when getting split rules for a node of an unregistered type'
|
2012-04-30 23:36:02 +00:00
|
|
|
);
|
2012-05-22 00:39:03 +00:00
|
|
|
factory.register( 'node-factory-node-stub', ve.ce.NodeFactoryNodeStub );
|
2012-07-10 19:46:08 +00:00
|
|
|
assert.strictEqual(
|
2012-05-22 00:39:03 +00:00
|
|
|
factory.canNodeBeSplit( 'node-factory-node-stub' ),
|
2012-04-30 23:36:02 +00:00
|
|
|
false,
|
|
|
|
'gets split rules for registered nodes'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2012-07-10 19:46:08 +00:00
|
|
|
test( 'initialization', 1, function( assert ) {
|
|
|
|
assert.ok( ve.ce.nodeFactory instanceof ve.ce.NodeFactory, 'factory is initialized at ve.ce.nodeFactory' );
|
2012-04-30 23:36:02 +00:00
|
|
|
} );
|