mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-11 05:56:11 +00:00
042ffb4e3b
* Added converters to all relevant node implementations * Added new annotation objects with their own factory Change-Id: I9870d6d5eac45083929d74d2e58917d0939ca917
35 lines
845 B
JavaScript
35 lines
845 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.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 );
|
|
strictEqual(
|
|
factory.canNodeBeSplit( 'node-factory-node-stub' ),
|
|
false,
|
|
'gets split rules for registered nodes'
|
|
);
|
|
} );
|
|
|
|
test( 'initialization', 1, function() {
|
|
ok( ve.ce.nodeFactory instanceof ve.ce.NodeFactory, 'factory is initialized at ve.ce.nodeFactory' );
|
|
} );
|