model.js 791 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. import Model from '/ckeditor5/core/ui/model.js';
  7. let Car, car;
  8. describe( 'Model', () => {
  9. beforeEach( () => {
  10. Car = class extends Model {};
  11. car = new Car( {
  12. color: 'red',
  13. year: 2015
  14. } );
  15. } );
  16. it( 'should set attributes on creation', () => {
  17. expect( car ).to.have.property( 'color', 'red' );
  18. expect( car ).to.have.property( 'year', 2015 );
  19. const spy = sinon.spy();
  20. car.on( 'change:color', spy );
  21. car.color = 'blue';
  22. expect( spy.called ).to.be.true;
  23. } );
  24. it( 'should add properties on creation', () => {
  25. let car = new Car( null, {
  26. prop: 1
  27. } );
  28. expect( car ).to.have.property( 'prop', 1 );
  29. } );
  30. } );