|
1 | 1 | import { expect } from '@esm-bundle/chai'; |
2 | | -import { fixtureSync } from '@vaadin/testing-helpers'; |
| 2 | +import { fixtureSync, nextFrame } from '@vaadin/testing-helpers'; |
3 | 3 | import sinon from 'sinon'; |
4 | 4 | import '../vaadin-icon.js'; |
5 | 5 | import { isSafari } from '@vaadin/component-base/src/browser-utils.js'; |
@@ -169,4 +169,54 @@ describe('vaadin-icon - icon fonts', () => { |
169 | 169 | expect(['"My icons"', 'My icons']).to.include(fontIconStyle.fontFamily); |
170 | 170 | }); |
171 | 171 | }); |
| 172 | + |
| 173 | + // These tests make sure that the heavy container query fallback is only used |
| 174 | + // when font icons are used. |
| 175 | + (usesFontIconSizingFallback ? describe : describe.skip)('container query fallback', () => { |
| 176 | + let icon; |
| 177 | + |
| 178 | + it('should have the custom property (font)', async () => { |
| 179 | + icon = fixtureSync('<vaadin-icon font="foo"></vaadin-icon>'); |
| 180 | + await nextFrame(); |
| 181 | + expect(icon.style.getPropertyValue('--_vaadin-font-icon-size')).to.equal('24px'); |
| 182 | + }); |
| 183 | + |
| 184 | + it('should have the custom property (char)', async () => { |
| 185 | + icon = fixtureSync('<vaadin-icon char="foo"></vaadin-icon>'); |
| 186 | + await nextFrame(); |
| 187 | + expect(icon.style.getPropertyValue('--_vaadin-font-icon-size')).to.equal('24px'); |
| 188 | + }); |
| 189 | + |
| 190 | + it('should not have the custom property', async () => { |
| 191 | + icon = fixtureSync('<vaadin-icon></vaadin-icon>'); |
| 192 | + await nextFrame(); |
| 193 | + expect(icon.style.getPropertyValue('--_vaadin-font-icon-size')).to.equal(''); |
| 194 | + }); |
| 195 | + |
| 196 | + it('should set the custom property', async () => { |
| 197 | + icon = fixtureSync('<vaadin-icon></vaadin-icon>'); |
| 198 | + await nextFrame(); |
| 199 | + icon.font = 'foo'; |
| 200 | + expect(icon.style.getPropertyValue('--_vaadin-font-icon-size')).to.equal('24px'); |
| 201 | + }); |
| 202 | + |
| 203 | + it('should update the custom property', async () => { |
| 204 | + icon = fixtureSync('<vaadin-icon font="foo"></vaadin-icon>'); |
| 205 | + await nextFrame(); |
| 206 | + icon.style.width = '100px'; |
| 207 | + icon.style.height = '100px'; |
| 208 | + await onceResized(icon); |
| 209 | + expect(icon.style.getPropertyValue('--_vaadin-font-icon-size')).to.equal('100px'); |
| 210 | + }); |
| 211 | + |
| 212 | + it('should not update the custom property', async () => { |
| 213 | + icon = fixtureSync('<vaadin-icon></vaadin-icon>'); |
| 214 | + await nextFrame(); |
| 215 | + icon.style.width = '100px'; |
| 216 | + icon.style.height = '100px'; |
| 217 | + await nextFrame(icon); |
| 218 | + await nextFrame(icon); |
| 219 | + expect(icon.style.getPropertyValue('--_vaadin-font-icon-size')).to.equal(''); |
| 220 | + }); |
| 221 | + }); |
172 | 222 | }); |
0 commit comments