ConnectionMatchersSpec.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import {
  2. create
  3. } from 'lib/model';
  4. describe('matchers/ConnectionMatchers', function() {
  5. var connectionWaypoints = [
  6. { x: 100, y: 100, original: { x: 120, y: 120 } },
  7. { x: 80, y: 80, original: { x: 50, y: 50 } }
  8. ];
  9. var connection = create('connection', {
  10. id: 'someConnection',
  11. waypoints: connectionWaypoints
  12. });
  13. describe('waypoints', function() {
  14. it('should .have.waypoints() with Connection', function() {
  15. // given
  16. var expectedWaypoints = [
  17. { x: 100, y: 100 },
  18. { x: 80, y: 80 }
  19. ];
  20. // then
  21. expect(connection).to.have.waypoints(expectedWaypoints);
  22. });
  23. it('should .not.have.waypoints() with Connection', function() {
  24. // given
  25. var expectedWaypoints = [
  26. { x: 100, y: 100 },
  27. { x: 100, y: 80 } // wrong (!)
  28. ];
  29. // then
  30. expect(connection).not.to.have.waypoints(expectedWaypoints);
  31. });
  32. });
  33. describe('startDocking', function() {
  34. it('should .have.startDocking() with Connection', function() {
  35. // given
  36. var expectedStartDocking = {
  37. x: 120,
  38. y: 120
  39. };
  40. // then
  41. expect(connection).to.have.startDocking(expectedStartDocking);
  42. });
  43. it('should .not.have.startDocking() with Connection', function() {
  44. // given
  45. var expectedStartDocking = {
  46. x: 70, // wrong (!)
  47. y: 120
  48. };
  49. // then
  50. expect(connection).not.to.have.startDocking(expectedStartDocking);
  51. });
  52. });
  53. describe('endDocking', function() {
  54. it('should .have.endDocking() with Connection', function() {
  55. // given
  56. var expectedEndDocking = {
  57. x: 50,
  58. y: 50
  59. };
  60. // then
  61. expect(connection).to.have.endDocking(expectedEndDocking);
  62. });
  63. it('should .not.have.endDocking() with Connection', function() {
  64. // given
  65. var expectedEndDocking = {
  66. x: 50,
  67. y: 70 // wrong (!)
  68. };
  69. // then
  70. expect(connection).not.to.have.endDocking(expectedEndDocking);
  71. });
  72. });
  73. });