8
0

model.js 809 B

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