You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3KB

  1. // Test the core element functionality
  2. describe('Core element tests', function() {
  3. it ('should transition model properties', function() {
  4. var element = new Chart.Element({
  5. _model: {
  6. numberProp: 0,
  7. numberProp2: 100,
  8. _underscoreProp: 0,
  9. stringProp: 'abc',
  10. objectProp: {
  11. myObject: true
  12. },
  13. colorProp: 'rgb(0, 0, 0)'
  14. }
  15. });
  16. // First transition clones model into view
  17. element.transition(0.25);
  18. expect(element._view).toEqual(element._model);
  19. expect(element._start).toEqual(element._model); // also cloned
  20. expect(element._view.objectProp).toBe(element._model.objectProp); // not cloned
  21. expect(element._start.objectProp).toEqual(element._model.objectProp); // not cloned
  22. element._model.numberProp = 100;
  23. element._model.numberProp2 = 250;
  24. element._model._underscoreProp = 200;
  25. element._model.stringProp = 'def'
  26. element._model.newStringProp = 'newString';
  27. element._model.colorProp = 'rgb(255, 255, 0)'
  28. element.transition(0.25);
  29. expect(element._view).toEqual({
  30. numberProp: 25,
  31. numberProp2: 137.5,
  32. _underscoreProp: 0, // underscore props are not transition to a new value
  33. stringProp: 'def',
  34. newStringProp: 'newString',
  35. objectProp: {
  36. myObject: true
  37. },
  38. colorProp: 'rgb(64, 64, 0)',
  39. });
  40. });
  41. });