Skip to content

Commit

Permalink
chore(outline): depend on selection module
Browse files Browse the repository at this point in the history
Previously it was the other way around, now outline is optional,
building on top of selection.
  • Loading branch information
nikku authored and misiekhardcore committed Oct 31, 2024
1 parent b3863a2 commit b140578
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 45 deletions.
5 changes: 5 additions & 0 deletions lib/features/outline/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import Outline from './Outline';
import MultiSelectionOutline from './MultiSelectionOutline';

import SelectionModule from '../selection';

/**
* @type { import('didi').ModuleDeclaration }
*/
export default {
__depends__: [
SelectionModule
],
__init__: [ 'outline', 'multiSelectionOutline' ],
outline: [ 'type', Outline ],
multiSelectionOutline: [ 'type', MultiSelectionOutline ]
Expand Down
73 changes: 31 additions & 42 deletions test/spec/features/outline/MultiSelectionOutlineSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,60 @@ import {
inject,
} from 'test/TestHelper';

import selectionModule from 'lib/features/selection';
import outlineModule from 'lib/features/outline';

import {
classes as domClasses,
query as domQuery
} from 'min-dom';

describe('features/outline/MultiSelectionOutline', function() {

beforeEach(bootstrapDiagram({ modules: [ selectionModule ] }));
describe('features/outline - MultiSelectionOutline', function() {

describe('bootstrap', function() {
beforeEach(bootstrapDiagram({ modules: [ outlineModule ] }));

beforeEach(bootstrapDiagram({ modules: [ selectionModule ] }));

it('should bootstrap diagram with component', inject(function() {
var shape1, shape2, outline;

}));
beforeEach(inject(function(elementFactory, canvas, selection) {
shape1 = elementFactory.createShape({
id: 'shape1',
x: 100, y: 100, width: 100, height: 100
});

});
shape2 = elementFactory.createShape({
id: 'shape2',
x: 300, y: 100, width: 100, height: 100
});

canvas.addShape(shape1);
canvas.addShape(shape2);

describe('multi selection outline', function() {
selection.select([ shape1, shape2 ]);

var shape1, shape2, outline;
outline = domQuery('.djs-selection-outline');

beforeEach(inject(function(elementFactory, canvas, selection) {
shape1 = elementFactory.createShape({
id: 'shape1',
x: 100, y: 100, width: 100, height: 100
});
}));

shape2 = elementFactory.createShape({
id: 'shape2',
x: 300, y: 100, width: 100, height: 100
});

canvas.addShape(shape1);
canvas.addShape(shape2);
it('should show box', inject(function() {
expect(outline).to.exist;
}));

selection.select([ shape1, shape2 ]);

outline = domQuery('.djs-selection-outline');
it('should add djs-multi-select marker', inject(function(selection, canvas) {

}));
// when
var element = canvas.getContainer();

// then
expect(domClasses(element).has('djs-multi-select')).to.be.true;

it('should show box', inject(function() {
expect(outline).to.exist;
}));
// but when
selection.select(null);

// then
expect(domClasses(element).has('djs-multi-select')).to.be.false;
}));

it('should add djs-multi-select marker', inject(function(selection, canvas) {

// when
var element = canvas.getContainer();

// then
expect(domClasses(element).has('djs-multi-select')).to.be.true;

// but when
selection.select(null);

// then
expect(domClasses(element).has('djs-multi-select')).to.be.false;
}));
});
});
7 changes: 4 additions & 3 deletions test/spec/features/outline/OutlineSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
inject
} from 'test/TestHelper';

import selectionModule from 'lib/features/selection';
import outlineModule from 'lib/features/outline';

import {
query as domQuery
Expand All @@ -16,9 +16,10 @@ import {
} from 'tiny-svg';


describe('features/outline/Outline', function() {
describe('features/outline - Outline', function() {

beforeEach(bootstrapDiagram({ modules: [ outlineModule ] }));

beforeEach(bootstrapDiagram({ modules: [ selectionModule ] }));

it('should expose API', inject(function(outline) {

Expand Down

0 comments on commit b140578

Please sign in to comment.