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 */
|
|
|
|
|
|
|
|
test( 'canNodeBeSplit', 2, function() {
|
|
|
|
var factory = new ve.ce.NodeFactory();
|
|
|
|
raises( function() {
|
2012-05-22 00:39:03 +00:00
|
|
|
factory.create( 'node-factory-node-stub', 23, { 'bar': 'baz' } );
|
2012-04-30 23:36:02 +00:00
|
|
|
},
|
2012-05-22 00:39:03 +00:00
|
|
|
/^Unknown node type: node-factory-node-stub$/,
|
2012-04-30 23:36:02 +00:00
|
|
|
'throws an exception when getting allowed child nodes of a node of an unregistered type'
|
|
|
|
);
|
2012-05-22 00:39:03 +00:00
|
|
|
factory.register( 'node-factory-node-stub', ve.ce.NodeFactoryNodeStub );
|
2012-04-30 23:36:02 +00:00
|
|
|
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'
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
test( 'initialization', 1, function() {
|
|
|
|
ok( ve.ce.factory instanceof ve.ce.NodeFactory, 'factory is initialized at ve.ce.factory' );
|
|
|
|
} );
|