@@ -12,40 +12,60 @@ governing permissions and limitations under the License.
12
12
13
13
import '@spectrum-web-components/button/sp-clear-button.js' ;
14
14
import { ClearButton } from '@spectrum-web-components/button' ;
15
+ import { ElementSize } from '@spectrum-web-components/base' ;
15
16
import { expect , fixture , html } from '@open-wc/testing' ;
16
17
import { testForLitDevWarnings } from '../../../test/testing-helpers' ;
17
18
18
19
describe ( 'Clear Button' , ( ) => {
19
20
testForLitDevWarnings (
20
21
async ( ) =>
21
- await fixture < ClearButton > (
22
- html `
23
- < sp-clear-button size ="m " label ="Clear "> </ sp-clear-button >
24
- `
25
- )
22
+ await fixture < ClearButton > ( html `
23
+ < sp-clear-button size ="m " label ="Clear "> </ sp-clear-button >
24
+ ` )
26
25
) ;
27
- (
28
- [ 's' , 'm' , 'l' , 'xl' ] as (
29
- | 'xxs'
30
- | 'xs'
31
- | 's'
32
- | 'm'
33
- | 'l'
34
- | 'xl'
35
- | 'xxl'
36
- ) [ ]
37
- ) . map ( ( size ) => {
26
+ ( [ 's' , 'm' , 'l' , 'xl' ] as ElementSize [ ] ) . map ( ( size ) => {
38
27
it ( `loads - ${ size } ` , async ( ) => {
39
- const el = await fixture < ClearButton > (
40
- html `
41
- < sp-clear-button
42
- size =${ size }
43
- label ="Clear"
44
- > </ sp-clear-button >
45
- `
46
- ) ;
28
+ const el = await fixture < ClearButton > ( html `
29
+ < sp-clear-button size =${ size } label ="Clear"> </ sp-clear-button >
30
+ ` ) ;
47
31
48
32
await expect ( el ) . to . be . accessible ( ) ;
49
33
} ) ;
50
34
} ) ;
35
+
36
+ describe ( 'dev mode' , ( ) => {
37
+ let consoleStub : SinonStub ;
38
+ before ( ( ) => {
39
+ window . __swc . verbose = true ;
40
+ consoleStub = stub ( console , 'warn' ) ;
41
+ } ) ;
42
+
43
+ after ( ( ) => {
44
+ window . __swc . verbose = false ;
45
+ consoleStub . restore ( ) ;
46
+ } ) ;
47
+
48
+ it ( 'should log dev warning when overBackground variant is used' , async ( ) => {
49
+ const el = await fixture < ClearButton > ( html `
50
+ < sp-clear-button
51
+ label ="Clear "
52
+ variant ="overBackground "
53
+ > </ sp-clear-button >
54
+ ` ) ;
55
+
56
+ await elementUpdated ( el ) ;
57
+
58
+ const warning = consoleStub . getCall ( 0 ) . args . at ( 0 ) ;
59
+ const expectedContent =
60
+ 'The overBackground variant is deprecated. Please use `static-color="white"` instead.' ;
61
+
62
+ expect ( consoleStub ) . to . be . calledOnce ;
63
+ expect ( warning . includes ( expectedContent ) ) . to . be . true ;
64
+
65
+ // Check that the staticColor is set to white
66
+ expect ( el . staticColor ) . to . equal ( 'white' ) ;
67
+ expect ( el . hasAttribute ( 'static-color' ) ) . to . be . true ;
68
+ expect ( el . getAttribute ( 'static-color' ) ) . to . equal ( 'white' ) ;
69
+ } ) ;
70
+ } ) ;
51
71
} ) ;
0 commit comments