8
0

createdocumentmock.js 965 B

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import createDocumentMock from '../../../tests/view/_utils/createdocumentmock';
  6. describe( 'createDocumentMock', () => {
  7. it( 'should create document mock', () => {
  8. const docMock = createDocumentMock();
  9. const rootMock = {};
  10. const isFocusedSpy = sinon.spy();
  11. const isReadOnlySpy = sinon.spy();
  12. docMock.on( 'change:selectedEditable', ( evt, key, value ) => {
  13. expect( value ).to.equal( rootMock );
  14. } );
  15. docMock.on( 'change:isFocused', isFocusedSpy );
  16. docMock.on( 'change:isReadOnly', isReadOnlySpy );
  17. docMock.isFocused = true;
  18. docMock.isReadOnly = true;
  19. sinon.assert.calledOnce( isFocusedSpy );
  20. expect( isFocusedSpy.lastCall.args[ 2 ] ).to.true;
  21. sinon.assert.calledOnce( isReadOnlySpy );
  22. expect( isReadOnlySpy.lastCall.args[ 2 ] ).to.true;
  23. } );
  24. } );