|
@@ -9,14 +9,16 @@
|
|
|
|
|
|
|
|
var modules = bender.amd.require(
|
|
var modules = bender.amd.require(
|
|
|
'document/transaction',
|
|
'document/transaction',
|
|
|
- 'document/deltas/delta' );
|
|
|
|
|
|
|
+ 'document/deltas/delta',
|
|
|
|
|
+ 'ckeditorerror' );
|
|
|
|
|
|
|
|
describe( 'Transaction', () => {
|
|
describe( 'Transaction', () => {
|
|
|
- var Transaction, Delta;
|
|
|
|
|
|
|
+ var Transaction, Delta, CKEditorError;
|
|
|
|
|
|
|
|
before( () => {
|
|
before( () => {
|
|
|
Transaction = modules[ 'document/transaction' ];
|
|
Transaction = modules[ 'document/transaction' ];
|
|
|
Delta = modules[ 'document/deltas/delta' ];
|
|
Delta = modules[ 'document/deltas/delta' ];
|
|
|
|
|
+ CKEditorError = modules.ckeditorerror;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
it( 'should have registered basic methods', () => {
|
|
it( 'should have registered basic methods', () => {
|
|
@@ -75,7 +77,7 @@ describe( 'Transaction', () => {
|
|
|
|
|
|
|
|
var transaction = new Transaction( doc );
|
|
var transaction = new Transaction( doc );
|
|
|
|
|
|
|
|
- var stub = sinon.stub().returns( new TestDelta( transaction ) );
|
|
|
|
|
|
|
+ var stub = sinon.stub();
|
|
|
|
|
|
|
|
Transaction.register( 'foo', stub );
|
|
Transaction.register( 'foo', stub );
|
|
|
|
|
|
|
@@ -83,5 +85,13 @@ describe( 'Transaction', () => {
|
|
|
|
|
|
|
|
sinon.assert.calledWith( stub, doc, transaction, arg );
|
|
sinon.assert.calledWith( stub, doc, transaction, arg );
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'should throw if one try to register the same transaction twice', () => {
|
|
|
|
|
+ Transaction.register( 'foo', () => {} );
|
|
|
|
|
+
|
|
|
|
|
+ expect( () => {
|
|
|
|
|
+ Transaction.register( 'foo', () => {} );
|
|
|
|
|
+ } ).to.throw( CKEditorError, /^transaction-register-taken/ );
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|