mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
dc27d8acb4
* Moved implementation of getting and updating a DOM wrapper to ve.ce.BranchNode * Updated ve.ce.BranchNode tests * Renamed ve.NodeFactory.createNode to ve.NodeFactory.create * Added ve.NodeFactory.lookup which gets the constructor of a type * Added attribute pass-through to ve.dm.BranchNodeStub Change-Id: I8f5b7d3d3ae616cc5f39828b24b655163d782ae5
35 lines
786 B
JavaScript
35 lines
786 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.create( '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' );
|
|
} );
|