Catalog alignment
[sdc.git] / catalog-ui / src / app / ng2 / pages / composition / graph / common / style / component-instances-nodes-style.spec.ts
1 import {async} from "@angular/core/testing";
2 import {ComponentInstanceNodesStyle} from "./component-instances-nodes-style";
3
4
5 describe('component instance nodes style component', () => {
6
7     beforeEach(
8         async(() => {
9             const createElement = document.createElement.bind(document);
10             document.createElement = (tagName) => {
11                 if (tagName === 'canvas') {
12                     return {
13                         getContext: () => ({
14                             font: "",
15                             measureText: (x) => ({width: x.length})
16                         }),
17                     };
18                 }
19                 return createElement(tagName);
20             };
21         })
22     );
23
24     it('verify getGraphDisplayName for String.length smaller than 67 chars', () => {
25         let inputString = 'SomeText';
26         let expectedRes = inputString;
27         let res = ComponentInstanceNodesStyle.getGraphDisplayName(inputString);
28         expect(res).toBe(expectedRes);
29     });
30
31     it('verify getGraphDisplayName for String.length greater than 67 chars', () => {
32         let inputString = 'AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEFFFFFFFFFFGGGGGGGGGG12345678';
33         let expectedRes = 'AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEFFFFFFFFF...';
34         let res = ComponentInstanceNodesStyle.getGraphDisplayName(inputString);
35         expect(res).toBe(expectedRes);
36     });
37 }