| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
QUnit.module( 've.ce.NodeFactory' ); |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
ve.ce.NodeFactoryNodeStub = function VeCeNodeFactoryNodeStub() {}; |
| 12 |
|
| 13 |
OO.inheritClass( ve.ce.NodeFactoryNodeStub, ve.ce.LeafNode ); |
| 14 |
|
| 15 |
ve.ce.NodeFactoryNodeStub.static.splitOnEnter = true; |
| 16 |
|
| 17 |
ve.ce.NodeFactoryNodeStub.static.name = 'node-factory-node-stub'; |
| 18 |
|
| 19 |
ve.ce.NodeFactoryNodeStub.static.getDescription = function () { |
| 20 |
return 'description'; |
| 21 |
}; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
QUnit.test( 'splitNodeOnEnter/getDescription', ( assert ) => { |
| 26 |
const factory = new ve.ce.NodeFactory(); |
| 27 |
|
| 28 |
assert.throws( |
| 29 |
() => { |
| 30 |
factory.splitNodeOnEnter( 'node-factory-node-stub' ); |
| 31 |
}, |
| 32 |
Error, |
| 33 |
'throws an exception when calling splitNodeOnEnter on an unregistered type' |
| 34 |
); |
| 35 |
|
| 36 |
assert.throws( |
| 37 |
() => { |
| 38 |
factory.getDescription( new ve.dm.NodeFactoryNodeStub() ); |
| 39 |
}, |
| 40 |
Error, |
| 41 |
'throws an exception when calling getDescription on an unregistered type' |
| 42 |
); |
| 43 |
|
| 44 |
factory.register( ve.ce.NodeFactoryNodeStub ); |
| 45 |
|
| 46 |
assert.strictEqual( |
| 47 |
factory.splitNodeOnEnter( 'node-factory-node-stub' ), |
| 48 |
true, |
| 49 |
'splitNodeOnEnter' |
| 50 |
); |
| 51 |
|
| 52 |
assert.strictEqual( |
| 53 |
factory.getDescription( new ve.dm.NodeFactoryNodeStub() ), |
| 54 |
'description', |
| 55 |
'getDescription' |
| 56 |
); |
| 57 |
} ); |
| 58 |
|
| 59 |
QUnit.test( 'initialization', ( assert ) => { |
| 60 |
assert.true( ve.ce.nodeFactory instanceof ve.ce.NodeFactory, 'factory is initialized at ve.ce.nodeFactory' ); |
| 61 |
} ); |