11import sinon from 'sinon' ;
22import { VscodeButton } from './index.js' ;
33import { expect , fixture , html } from '@open-wc/testing' ;
4+ import { $ } from '../includes/test-helpers.js' ;
45
56describe ( 'vscode-button' , ( ) => {
67 it ( 'is defined' , ( ) => {
@@ -78,7 +79,9 @@ describe('vscode-button', () => {
7879 `
7980 <div class="base" part="base">
8081 <vscode-icon name="account" class="icon"></vscode-icon>
82+ <slot name="content-before"></slot>
8183 <slot></slot>
84+ <slot name="content-after"></slot>
8285 </div>
8386 `
8487 ) ;
@@ -93,7 +96,9 @@ describe('vscode-button', () => {
9396 `
9497 <div class="base" part="base">
9598 <vscode-icon name="account" spin class="icon"></vscode-icon>
99+ <slot name="content-before"></slot>
96100 <slot></slot>
101+ <slot name="content-after"></slot>
97102 </div>
98103 `
99104 ) ;
@@ -111,7 +116,9 @@ describe('vscode-button', () => {
111116 `
112117 <div class="base" part="base">
113118 <vscode-icon name="account" class="icon" spin-duration="5"></vscode-icon>
119+ <slot name="content-before"></slot>
114120 <slot></slot>
121+ <slot name="content-after"></slot>
115122 </div>
116123 `
117124 ) ;
@@ -125,7 +132,9 @@ describe('vscode-button', () => {
125132 expect ( el ) . shadowDom . to . eq (
126133 `
127134 <div class="base" part="base">
135+ <slot name="content-before"></slot>
128136 <slot></slot>
137+ <slot name="content-after"></slot>
129138 <vscode-icon name="account" class="icon-after"></vscode-icon>
130139 </div>
131140 `
@@ -140,7 +149,9 @@ describe('vscode-button', () => {
140149 expect ( el ) . shadowDom . to . eq (
141150 `
142151 <div class="base" part="base">
152+ <slot name="content-before"></slot>
143153 <slot></slot>
154+ <slot name="content-after"></slot>
144155 <vscode-icon name="account" class="icon-after" spin></vscode-icon>
145156 </div>
146157 `
@@ -158,7 +169,9 @@ describe('vscode-button', () => {
158169 expect ( el ) . shadowDom . to . eq (
159170 `
160171 <div class="base" part="base">
172+ <slot name="content-before"></slot>
161173 <slot></slot>
174+ <slot name="content-after"></slot>
162175 <vscode-icon name="account" class="icon-after" spin-duration="5"></vscode-icon>
163176 </div>
164177 `
@@ -199,5 +212,25 @@ describe('vscode-button', () => {
199212 expect ( submitSpy . called ) . to . be . true ;
200213 } ) ;
201214
215+ it ( 'adds custom class to wrapper if content-before slot is not empty' , async ( ) => {
216+ const el = await fixture < VscodeButton > (
217+ html `< vscode-button > < b slot ="content-before "> b</ b > </ vscode-button > `
218+ ) ;
219+
220+ const base = $ ( el . shadowRoot ! , '.base' ) ;
221+
222+ expect ( base . classList . contains ( 'has-content-before' ) ) . to . be . true ;
223+ } ) ;
224+
225+ it ( 'adds custom class to wrapper if content-after slot is not empty' , async ( ) => {
226+ const el = await fixture < VscodeButton > (
227+ html `< vscode-button > < b slot ="content-after "> b</ b > </ vscode-button > `
228+ ) ;
229+
230+ const base = $ ( el . shadowRoot ! , '.base' ) ;
231+
232+ expect ( base . classList . contains ( 'has-content-after' ) ) . to . be . true ;
233+ } ) ;
234+
202235 it ( 'sets the form value' ) ;
203236} ) ;
0 commit comments