mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
35 lines
790 B
JavaScript
35 lines
790 B
JavaScript
|
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() {
|
||
|
factory.createNode( 'stub', 23, { 'bar': 'baz' } );
|
||
|
},
|
||
|
/^Unknown node type: stub$/,
|
||
|
'throws an exception when getting allowed child nodes of a node of an unregistered type'
|
||
|
);
|
||
|
factory.register( 'stub', ve.ce.NodeFactoryNodeStub );
|
||
|
strictEqual(
|
||
|
factory.canNodeBeSplit( 'stub' ),
|
||
|
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' );
|
||
|
} );
|