mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
8d33a3de0d
* Made method descriptions imperative: "Do this" rather than "Does this" * Changed use of "this object" to "the object" in method documentation * Added missing documentation * Fixed incorrect documentation * Fixed incorrect debug method names (as in those VeDmClassName tags we add to functions so they make sense when dumped into in the console) * Normalized use of package names throughout * Normalized class descriptions * Removed incorrect @abstract tags * Added missing @method tags * Lots of other minor cleanup Change-Id: I4ea66a2dd107613e2ea3a5f56ff54d675d72957e
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable Node tests.
|
|
*
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
QUnit.module( 've.ce.Node' );
|
|
|
|
/* Stubs */
|
|
|
|
ve.ce.NodeStub = function VeCeNodeStub( model ) {
|
|
// Parent constructor
|
|
ve.ce.Node.call( this, 'stub', model );
|
|
};
|
|
|
|
ve.inheritClass( ve.ce.NodeStub, ve.ce.Node );
|
|
|
|
ve.ce.nodeFactory.register( 'stub', ve.ce.NodeStub );
|
|
|
|
/* Tests */
|
|
|
|
QUnit.test( 'getModel', 1, function ( assert ) {
|
|
var model = new ve.dm.NodeStub( 'stub', 0 ),
|
|
view = new ve.ce.NodeStub( model );
|
|
assert.strictEqual( view.getModel(), model, 'returns reference to model given to constructor' );
|
|
} );
|
|
|
|
QUnit.test( 'getParent', 1, function ( assert ) {
|
|
var a = new ve.ce.NodeStub( new ve.dm.NodeStub( 'stub', 0 ) );
|
|
assert.strictEqual( a.getParent(), null, 'returns null if not attached' );
|
|
} );
|
|
|
|
QUnit.test( 'attach', 2, function ( assert ) {
|
|
var a = new ve.ce.NodeStub( new ve.dm.NodeStub( 'stub', 0 ) ),
|
|
b = new ve.ce.NodeStub( new ve.dm.NodeStub( 'stub', 0 ) );
|
|
a.on( 'attach', function ( parent ) {
|
|
assert.strictEqual( parent, b, 'attach event is called with parent as first argument' );
|
|
} );
|
|
a.attach( b );
|
|
assert.strictEqual( a.getParent(), b, 'parent is set to given object after attach' );
|
|
} );
|
|
|
|
QUnit.test( 'detach', 2, function ( assert ) {
|
|
var a = new ve.ce.NodeStub( new ve.dm.NodeStub( 'stub', 0 ) ),
|
|
b = new ve.ce.NodeStub( new ve.dm.NodeStub( 'stub', 0 ) );
|
|
a.attach( b );
|
|
a.on( 'detach', function ( parent ) {
|
|
assert.strictEqual( parent, b, 'detach event is called with parent as first argument' );
|
|
} );
|
|
a.detach();
|
|
assert.strictEqual( a.getParent(), null, 'parent is set null after detach' );
|
|
} );
|