model.js 813 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 Model from '../src/model';
  6. let Car, car;
  7. describe( 'Model', () => {
  8. beforeEach( () => {
  9. Car = class extends Model {};
  10. car = new Car( {
  11. color: 'red',
  12. year: 2015
  13. } );
  14. } );
  15. it( 'should set attributes on creation', () => {
  16. expect( car ).to.have.property( 'color', 'red' );
  17. expect( car ).to.have.property( 'year', 2015 );
  18. const spy = sinon.spy();
  19. car.on( 'change:color', spy );
  20. car.color = 'blue';
  21. expect( spy.called ).to.be.true;
  22. } );
  23. it( 'should add properties on creation', () => {
  24. const car = new Car( null, {
  25. prop: 1
  26. } );
  27. expect( car ).to.have.property( 'prop', 1 );
  28. } );
  29. } );