|
1 | 1 | import { expect } from '@vaadin/chai-plugins';
|
2 |
| -import { aTimeout, fixtureSync, focusin, focusout, nextFrame, nextRender } from '@vaadin/testing-helpers'; |
| 2 | +import { aTimeout, fixtureSync, focusin, focusout, nextFrame, nextRender, outsideClick } from '@vaadin/testing-helpers'; |
| 3 | +import { sendKeys } from '@web/test-runner-commands'; |
3 | 4 | import sinon from 'sinon';
|
4 |
| -import '../vaadin-date-time-picker.js'; |
| 5 | +import '../src/vaadin-date-time-picker.js'; |
5 | 6 | import { changeInputValue } from './helpers.js';
|
6 | 7 |
|
7 | 8 | const fixtures = {
|
@@ -102,6 +103,52 @@ describe('Basic features', () => {
|
102 | 103 | });
|
103 | 104 | });
|
104 | 105 |
|
| 106 | + describe('pointer-events', () => { |
| 107 | + it('should not have by default', () => { |
| 108 | + expect(dateTimePicker.style.pointerEvents).to.be.empty; |
| 109 | + }); |
| 110 | + |
| 111 | + it('should set to `auto` when opening date-picker', async () => { |
| 112 | + datePicker.click(); |
| 113 | + await nextRender(); |
| 114 | + expect(dateTimePicker.style.pointerEvents).to.equal('auto'); |
| 115 | + }); |
| 116 | + |
| 117 | + it('should remove when closing date-picker', async () => { |
| 118 | + datePicker.click(); |
| 119 | + await nextRender(); |
| 120 | + outsideClick(); |
| 121 | + expect(dateTimePicker.style.pointerEvents).to.be.empty; |
| 122 | + }); |
| 123 | + |
| 124 | + it('should set to `auto` when opening time-picker', async () => { |
| 125 | + timePicker.click(); |
| 126 | + await nextRender(); |
| 127 | + expect(dateTimePicker.style.pointerEvents).to.equal('auto'); |
| 128 | + }); |
| 129 | + |
| 130 | + it('should remove when closing time-picker', async () => { |
| 131 | + timePicker.click(); |
| 132 | + await nextRender(); |
| 133 | + outsideClick(); |
| 134 | + expect(dateTimePicker.style.pointerEvents).to.be.empty; |
| 135 | + }); |
| 136 | + |
| 137 | + it('should keep `auto` when switching between pickers', async () => { |
| 138 | + datePicker.click(); |
| 139 | + await nextRender(); |
| 140 | + expect(dateTimePicker.style.pointerEvents).to.equal('auto'); |
| 141 | + |
| 142 | + timePicker.click(); |
| 143 | + await nextRender(); |
| 144 | + expect(dateTimePicker.style.pointerEvents).to.equal('auto'); |
| 145 | + |
| 146 | + datePicker.click(); |
| 147 | + await nextRender(); |
| 148 | + expect(dateTimePicker.style.pointerEvents).to.equal('auto'); |
| 149 | + }); |
| 150 | + }); |
| 151 | + |
105 | 152 | describe('focused', () => {
|
106 | 153 | it('should set focused attribute on date-picker focusin', () => {
|
107 | 154 | focusin(datePicker);
|
@@ -140,6 +187,61 @@ describe('Basic features', () => {
|
140 | 187 | });
|
141 | 188 | });
|
142 | 189 |
|
| 190 | + describe('date-picker focused', () => { |
| 191 | + it('should remove focused attribute on time-picker click', async () => { |
| 192 | + datePicker.focus(); |
| 193 | + datePicker.click(); |
| 194 | + await nextRender(); |
| 195 | + expect(datePicker.hasAttribute('focused')).to.be.true; |
| 196 | + |
| 197 | + timePicker.focus(); |
| 198 | + timePicker.click(); |
| 199 | + expect(datePicker.hasAttribute('focused')).to.be.false; |
| 200 | + }); |
| 201 | + |
| 202 | + it('should remove focus-ring attribute on time-picker click', async () => { |
| 203 | + // Focus the date-picker with the keyboard |
| 204 | + await sendKeys({ press: 'Tab' }); |
| 205 | + // Open the overlay with the keyboard |
| 206 | + await sendKeys({ press: 'ArrowDown' }); |
| 207 | + await nextRender(); |
| 208 | + expect(datePicker.hasAttribute('focus-ring')).to.be.true; |
| 209 | + |
| 210 | + timePicker.focus(); |
| 211 | + timePicker.click(); |
| 212 | + expect(datePicker.hasAttribute('focus-ring')).to.be.false; |
| 213 | + }); |
| 214 | + }); |
| 215 | + |
| 216 | + describe('time-picker focused', () => { |
| 217 | + it('should remove focused attribute on date-picker click', async () => { |
| 218 | + timePicker.focus(); |
| 219 | + timePicker.click(); |
| 220 | + await nextRender(); |
| 221 | + expect(timePicker.hasAttribute('focused')).to.be.true; |
| 222 | + |
| 223 | + datePicker.focus(); |
| 224 | + datePicker.click(); |
| 225 | + await nextRender(); |
| 226 | + expect(timePicker.hasAttribute('focused')).to.be.false; |
| 227 | + }); |
| 228 | + |
| 229 | + it('should remove focus-ring attribute on date-picker click', async () => { |
| 230 | + // Focus the time-picker with the keyboard |
| 231 | + await sendKeys({ press: 'Tab' }); |
| 232 | + await sendKeys({ press: 'Tab' }); |
| 233 | + // Open the overlay with the keyboard |
| 234 | + await sendKeys({ press: 'ArrowDown' }); |
| 235 | + await nextRender(); |
| 236 | + expect(timePicker.hasAttribute('focus-ring')).to.be.true; |
| 237 | + |
| 238 | + datePicker.focus(); |
| 239 | + datePicker.click(); |
| 240 | + await nextRender(); |
| 241 | + expect(timePicker.hasAttribute('focus-ring')).to.be.false; |
| 242 | + }); |
| 243 | + }); |
| 244 | + |
143 | 245 | describe('change event', () => {
|
144 | 246 | let spy;
|
145 | 247 |
|
|
0 commit comments