123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import {
- bootstrapDiagram,
- inject
- } from 'test/TestHelper';
- import selectionModule from 'lib/features/selection';
- import {
- query as domQuery
- } from 'min-dom';
- import {
- classes as svgClasses
- } from 'tiny-svg';
- describe('features/outline/Outline', function() {
- beforeEach(bootstrapDiagram({ modules: [ selectionModule ] }));
- it('should expose API', inject(function(outline) {
- expect(outline).to.exist;
- expect(outline.updateShapeOutline).to.exist;
- expect(outline.updateConnectionOutline).to.exist;
- }));
- describe('select', function() {
- it('should add outline to shape', inject(function(selection, canvas, elementRegistry) {
- // given
- var shape = canvas.addShape({
- id: 'test',
- x: 10,
- y: 10,
- width: 100,
- height: 100
- });
- // when
- selection.select(shape);
- // then
- var gfx = elementRegistry.getGraphics(shape);
- var outline = domQuery('.djs-outline', gfx);
- expect(outline).to.exist;
- expect(svgClasses(gfx).has('selected')).to.be.true; // Outline class is set
- }));
- it('should add outline to connection', inject(function(selection, canvas, elementRegistry) {
- // given
- var connection = canvas.addConnection({ id: 'select1', waypoints: [ { x: 25, y: 25 }, { x: 115, y: 115 } ] });
- // when
- selection.select(connection);
- // then
- var gfx = elementRegistry.getGraphics(connection);
- var outline = domQuery('.djs-outline', gfx);
- expect(outline).to.exist;
- expect(svgClasses(gfx).has('selected')).to.be.true; // Outline class is set
- }));
- });
- describe('deselect', function() {
- it('should remove outline class from shape', inject(function(selection, canvas, elementRegistry) {
- // given
- var shape = canvas.addShape({
- id: 'test',
- x: 10,
- y: 10,
- width: 100,
- height: 100
- });
- // when
- selection.select(shape);
- selection.deselect(shape);
- // then
- var gfx = elementRegistry.getGraphics(shape);
- var outline = domQuery('.djs-outline', gfx);
- expect(outline).to.exist;
- expect(svgClasses(gfx).has('selected')).to.be.false; // Outline class is not set
- }));
- it('should remove outline class from connection', inject(function(selection, canvas, elementRegistry) {
- // given
- var connection = canvas.addConnection({ id: 'select3', waypoints: [ { x: 25, y: 25 }, { x: 115, y: 115 } ] });
- // when
- selection.select(connection);
- selection.deselect(connection);
- // then
- var gfx = elementRegistry.getGraphics(connection);
- var outline = domQuery('.djs-outline', gfx);
- expect(outline).to.exist;
- expect(svgClasses(gfx).has('selected')).to.be.false; // Outline class is not set
- }));
- });
- });
|