2012-05-04 22:29:47 +00:00
|
|
|
module( 've.dm.Surface' );
|
|
|
|
|
|
|
|
ve.dm.SurfaceStub = function() {
|
|
|
|
// Inheritance
|
|
|
|
this.dm = new ve.dm.Document ( [{ 'type': 'paragraph' }, 'hi', { 'type': '/paragraph' }] );
|
|
|
|
ve.dm.Surface.call( this, this.dm );
|
|
|
|
};
|
|
|
|
|
|
|
|
// Inheritance
|
|
|
|
|
|
|
|
ve.extendClass( ve.dm.SurfaceStub, ve.dm.Surface );
|
|
|
|
|
|
|
|
// Tests
|
|
|
|
|
2012-05-07 18:58:02 +00:00
|
|
|
test( 'getDocument', 1, function() {
|
2012-05-04 22:29:47 +00:00
|
|
|
var surface = new ve.dm.SurfaceStub();
|
|
|
|
strictEqual( surface.getDocument(), surface.documentModel );
|
2012-05-07 18:58:02 +00:00
|
|
|
} );
|
2012-05-04 22:29:47 +00:00
|
|
|
|
2012-05-07 18:58:02 +00:00
|
|
|
test( 'getSelection', 1, function() {
|
2012-05-04 22:29:47 +00:00
|
|
|
var surface = new ve.dm.SurfaceStub();
|
|
|
|
strictEqual( surface.getSelection(), surface.selection );
|
2012-05-07 18:58:02 +00:00
|
|
|
} );
|
2012-05-04 22:29:47 +00:00
|
|
|
|
2012-05-07 18:58:02 +00:00
|
|
|
test( 'setSelection', 1, function() {
|
2012-05-04 22:29:47 +00:00
|
|
|
var surface = new ve.dm.SurfaceStub();
|
2012-05-07 18:58:02 +00:00
|
|
|
surface.on( 'select', function() {
|
2012-05-04 22:29:47 +00:00
|
|
|
ok( true, 'select was emitted' );
|
2012-05-07 18:58:02 +00:00
|
|
|
} );
|
2012-05-04 22:29:47 +00:00
|
|
|
surface.setSelection( new ve.Range( 1, 1 ) );
|
2012-05-07 18:58:02 +00:00
|
|
|
} );
|
2012-05-04 22:29:47 +00:00
|
|
|
|
2012-05-07 18:58:02 +00:00
|
|
|
test( 'transact', 1, function() {
|
2012-05-04 22:29:47 +00:00
|
|
|
var surface = new ve.dm.SurfaceStub();
|
2012-05-04 23:13:54 +00:00
|
|
|
var tx = new ve.dm.Transaction();
|
2012-05-07 18:58:02 +00:00
|
|
|
surface.on( 'transact', function() {
|
|
|
|
ok( true, 'transact was emitted' );
|
|
|
|
} );
|
2012-05-04 22:29:47 +00:00
|
|
|
surface.transact( tx );
|
2012-05-07 18:58:02 +00:00
|
|
|
} );
|