1- import { html , fixture , expect } from '@open-wc/testing' ;
1+ import { html , fixture , expect , elementUpdated } from '@open-wc/testing' ;
22import { UUIColorSwatchElement } from './uui-color-swatch.element' ;
3+ import { sendMouse } from '@web/test-runner-commands' ;
34
45describe ( 'UUIColorSwatchElement' , ( ) => {
56 let element : UUIColorSwatchElement ;
@@ -17,4 +18,42 @@ describe('UUIColorSwatchElement', () => {
1718 it ( 'passes the a11y audit' , async ( ) => {
1819 await expect ( element ) . shadowDom . to . be . accessible ( ) ;
1920 } ) ;
21+
22+ describe ( 'selectable' , ( ) => {
23+ beforeEach ( async ( ) => {
24+ element . selectable = true ;
25+ } ) ;
26+
27+ it ( 'can be selected when selectable' , async ( ) => {
28+ await elementUpdated ( element ) ;
29+ await sendMouse ( {
30+ type : 'click' ,
31+ position : [ 15 , 15 ] ,
32+ button : 'left' ,
33+ } ) ;
34+ expect ( element . selected ) . to . be . true ;
35+ } ) ;
36+
37+ it ( 'can not be selected when not selectable' , async ( ) => {
38+ element . selectable = false ;
39+ await elementUpdated ( element ) ;
40+ await sendMouse ( {
41+ type : 'click' ,
42+ position : [ 15 , 15 ] ,
43+ button : 'left' ,
44+ } ) ;
45+ expect ( element . selected ) . to . be . false ;
46+ } ) ;
47+
48+ it ( 'cant be selected when disabled' , async ( ) => {
49+ element . disabled = true ;
50+ await elementUpdated ( element ) ;
51+ await sendMouse ( {
52+ type : 'click' ,
53+ position : [ 15 , 15 ] ,
54+ button : 'left' ,
55+ } ) ;
56+ expect ( element . selected ) . to . be . false ;
57+ } ) ;
58+ } ) ;
2059} ) ;
0 commit comments