mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-02 01:46:47 +00:00
aaa322642b
Also added tests for initialization of factories at ve.ce.factory and ve.dm.factory Change-Id: Ic6ac74aab86ecdfd4f094d9bb1fa16de930387b7
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' );
|
|
} );
|