-
Notifications
You must be signed in to change notification settings - Fork 7
/
temba-tip.test.ts
102 lines (90 loc) · 2.17 KB
/
temba-tip.test.ts
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { assert } from '@open-wc/testing';
import { Tip } from '../src/tip/Tip';
import { assertScreenshot, getClip, getComponent } from './utils.test';
const TAG = 'temba-tip';
const getTarget = () => {
return "<div style='line-height:0px;font-size:14px;background:green;display:flex'>👱♀️</div>";
};
const getTip = async (
attrs: { text?: string; position?: string; visible?: boolean } = {},
slot = getTarget()
) => {
const tip = (await getComponent(
TAG,
attrs,
slot,
20,
0,
'margin:200px;'
)) as Tip;
await tip.updateComplete;
return tip;
};
const getRightClip = (ele: HTMLElement) => {
const clip = getClip(ele);
clip.width += 78;
clip.height += 10;
clip.y -= 5;
return clip;
};
const getLeftClip = (ele: HTMLElement) => {
const clip = getClip(ele);
clip.x -= 80;
clip.width += 78;
clip.height += 10;
clip.y -= 5;
return clip;
};
const getTopClip = (ele: HTMLElement) => {
const clip = getClip(ele);
clip.y -= 30;
clip.height += 30;
clip.width += 30;
clip.x -= 15;
return clip;
};
const getBottomClip = (ele: HTMLElement) => {
const clip = getClip(ele);
clip.height += 35;
clip.width += 30;
clip.x -= 15;
return clip;
};
describe(TAG, () => {
it('can be created', async () => {
const icon = await getTip({ text: 'Resolve' });
assert.instanceOf(icon, Tip);
});
it('shows on the left', async () => {
const tip = await getTip({
text: 'Hello!',
visible: true,
position: 'left'
});
await assertScreenshot('tip/left', getLeftClip(tip));
});
it('shows on the right', async () => {
const tip = await getTip({
text: 'Hello!',
visible: true,
position: 'right'
});
await assertScreenshot('tip/right', getRightClip(tip));
});
it('shows on top', async () => {
const tip = await getTip({
text: 'Hello!',
visible: true,
position: 'top'
});
await assertScreenshot('tip/top', getTopClip(tip));
});
it('shows on bottom', async () => {
const tip = await getTip({
text: 'Hello!',
visible: true,
position: 'bottom'
});
await assertScreenshot('tip/bottom', getBottomClip(tip));
});
});