-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtemba-color-picker.test.ts
57 lines (48 loc) · 1.71 KB
/
temba-color-picker.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
import { assert } from '@open-wc/testing';
import { ColorPicker } from '../src/colorpicker/ColorPicker';
import { assertScreenshot, getClip, getComponent } from './utils.test';
const TAG = 'temba-color-picker';
const getPicker = async (attrs: any = {}) => {
const picker = (await getComponent(TAG, attrs, '', 400)) as ColorPicker;
return picker;
};
describe('temba-color-picker', () => {
it('renders default', async () => {
const picker: ColorPicker = await getPicker({
name: 'primary',
label: 'Primary Color'
});
assert.instanceOf(picker, ColorPicker);
await assertScreenshot('colorpicker/default', getClip(picker));
});
it('initializes value', async () => {
const picker: ColorPicker = await getPicker({
name: 'primary',
label: 'Primary Color',
value: '#2387ca'
});
await assertScreenshot('colorpicker/initialized', getClip(picker));
});
it('shows spectrum picker', async () => {
const picker: ColorPicker = await getPicker({
name: 'primary',
label: 'Primary Color',
value: '#2387ca'
});
(picker.shadowRoot.querySelector('.preview') as HTMLElement).click();
await assertScreenshot('colorpicker/focused', getClip(picker));
});
it('selects color', async () => {
const picker: ColorPicker = await getPicker({
name: 'primary',
label: 'Primary Color',
value: '#2387ca'
});
(picker.shadowRoot.querySelector('.preview') as HTMLElement).click();
const clip = getClip(picker);
// move our mouse over the count to show the summary
const page = window as any;
await page.mouseClick(clip.left + 200, clip.top + 35);
await assertScreenshot('colorpicker/selected', getClip(picker));
});
});