forked from antonioru/beautiful-react-diagrams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinkLabel.spec.js
32 lines (25 loc) · 1.1 KB
/
LinkLabel.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React from 'react';
import { render, cleanup } from '@testing-library/react';
import LinkLabel from '../dist/Diagram/Link/LinkLabel';
describe('LinkLabel component', () => {
afterEach(cleanup);
it('should render without explode', () => {
const { container } = render(<LinkLabel position={[10, 10]} label="foo" />);
should.exist(container);
expect(container.querySelector('foreignObject')).to.exist;
});
it('should have default classes', () => {
const { container } = render(<LinkLabel position={[10, 10]} label="foo" />);
const wrapper = container.querySelector('foreignObject > div');
expect(wrapper.getAttribute('class').split(' ')).to.include.members(['bi-diagram-link-label']);
});
it('should have label coordinates', () => {
const position = [10, 10];
const { container } = render(<LinkLabel position={position} label="foo" />);
const wrapper = container.querySelector('foreignObject');
const x = +wrapper.getAttribute('x');
const y = +wrapper.getAttribute('y');
expect(x).to.equal(position[0]);
expect(y).to.equal(position[1]);
});
});