|
1 | 1 | import { expect } from '@vaadin/chai-plugins'; |
2 | | -import { fixtureSync, nextFrame, nextRender, nextUpdate } from '@vaadin/testing-helpers'; |
| 2 | +import { fixtureSync, nextFrame, nextRender, nextResize, nextUpdate } from '@vaadin/testing-helpers'; |
3 | 3 | import sinon from 'sinon'; |
4 | 4 | import './draggable-resizable-styles.js'; |
5 | 5 | import '../src/vaadin-dialog.js'; |
@@ -245,18 +245,15 @@ describe('resizable', () => { |
245 | 245 | expect(container.offsetHeight).to.equal(resizeContainer.offsetHeight); |
246 | 246 | }); |
247 | 247 |
|
248 | | - it('should scroll if the content overflows', () => { |
| 248 | + it('should scroll if the content overflows', async () => { |
249 | 249 | // Fill the content with a lot of text so that it overflows the viewport |
250 | 250 | dialog.firstElementChild.textContent = new Array(10000).fill('foo').join(' '); |
| 251 | + await nextResize(dialog.firstElementChild); |
| 252 | + await nextRender(); |
251 | 253 |
|
252 | | - const resizeContainer = dialog.$.overlay.$.resizerContainer; |
253 | | - resizeContainer.scrollTop = 1; |
254 | | - expect(resizeContainer.scrollTop).to.equal(1); |
255 | | - |
256 | | - // TODO change to this with base styles |
257 | | - // const content = dialog.$.overlay.$.content; |
258 | | - // content.scrollTop = 1; |
259 | | - // expect(content.scrollTop).to.equal(1); |
| 254 | + const content = dialog.$.overlay.$.content; |
| 255 | + content.scrollTop = 1; |
| 256 | + expect(content.scrollTop).to.equal(1); |
260 | 257 | }); |
261 | 258 |
|
262 | 259 | it('should expand content with relative height', () => { |
@@ -301,7 +298,6 @@ describe('resizable', () => { |
301 | 298 | }); |
302 | 299 |
|
303 | 300 | it('should be able to resize dialog to be wider than window', async () => { |
304 | | - dialog.$.overlay.$.content.style.padding = '20px'; |
305 | 301 | dx = 20; |
306 | 302 | dialog.$.overlay.setBounds({ left: -dx }); |
307 | 303 | dx = Math.floor(window.innerWidth - bounds.width + 5); |
@@ -566,14 +562,17 @@ describe('draggable', () => { |
566 | 562 |
|
567 | 563 | it('should not reset scroll position on dragstart', async () => { |
568 | 564 | dialog.modeless = true; |
569 | | - button.style.marginBottom = '200px'; |
570 | | - dialog.$.overlay.setBounds({ height: '100px' }); |
571 | | - await nextUpdate(dialog); |
572 | | - // TODO use dialog.$.overlay.$.content.scrollTop with base styles |
573 | | - container.scrollTop = 100; |
574 | | - expect(container.scrollTop).to.equal(100); |
| 565 | + dialog.height = '100px'; |
| 566 | + await nextRender(); |
| 567 | + |
| 568 | + const contentElement = dialog.firstElementChild; |
| 569 | + contentElement.style.minHeight = '200px'; |
| 570 | + await nextResize(contentElement); |
| 571 | + await nextRender(); |
| 572 | + |
| 573 | + dialog.$.overlay.$.content.scrollTop = 100; |
575 | 574 | drag(container); |
576 | | - expect(container.scrollTop).to.equal(100); |
| 575 | + expect(dialog.$.overlay.$.content.scrollTop).to.equal(100); |
577 | 576 | }); |
578 | 577 |
|
579 | 578 | it('should update "top" and "left" properties on drag', async () => { |
@@ -855,13 +854,9 @@ describe('overflowing content', () => { |
855 | 854 | dialog.$.overlay.setBounds({ height: 200 }); |
856 | 855 | await nextFrame(); |
857 | 856 | overlay.$.content.style.padding = '20px'; |
858 | | - container.scrollTop = 100; |
859 | | - // TODO change to this with new base styles |
860 | | - // overlay.$.content.scrollTop = 100; |
| 857 | + overlay.$.content.scrollTop = 100; |
861 | 858 | resize(overlayPart.querySelector('.s'), 0, -50); |
862 | 859 | await nextFrame(); |
863 | | - expect(container.scrollTop).to.equal(100); |
864 | | - // TODO change to this with new base styles |
865 | | - // expect(overlay.$.content.scrollTop).to.equal(100); |
| 860 | + expect(overlay.$.content.scrollTop).to.equal(100); |
866 | 861 | }); |
867 | 862 | }); |
0 commit comments