|
1 | 1 | import { expect } from '@vaadin/chai-plugins'; |
2 | | -import { fixtureSync, nextRender, nextResize, nextUpdate } from '@vaadin/testing-helpers'; |
| 2 | +import { fixtureSync, nextRender, nextUpdate } from '@vaadin/testing-helpers'; |
3 | 3 | import sinon from 'sinon'; |
4 | 4 | import '../src/vaadin-dialog.js'; |
5 | 5 | import { createRenderer } from './helpers.js'; |
@@ -482,137 +482,6 @@ describe('header/footer feature', () => { |
482 | 482 | expect(getComputedStyle(headerPart).display).to.be.equal('none'); |
483 | 483 | }); |
484 | 484 | }); |
485 | | - |
486 | | - describe('overflow attribute', () => { |
487 | | - let content, headerHeight, footerHeight, contentHeight; |
488 | | - |
489 | | - beforeEach(async () => { |
490 | | - dialog.headerRenderer = createRenderer('Header'); |
491 | | - dialog.footerRenderer = createRenderer('Footer'); |
492 | | - dialog.renderer = createRenderer(Array(10).join('Lorem ipsum dolor sit amet\n')); |
493 | | - dialog.resizable = true; |
494 | | - dialog.opened = true; |
495 | | - await nextRender(); |
496 | | - content = overlay.$.content; |
497 | | - overlay.style.maxWidth = '300px'; |
498 | | - |
499 | | - headerHeight = overlay.shadowRoot.querySelector('[part=header]').offsetHeight; |
500 | | - footerHeight = overlay.shadowRoot.querySelector('[part=footer]').offsetHeight; |
501 | | - contentHeight = overlay.shadowRoot.querySelector('[part=content]').offsetHeight; |
502 | | - }); |
503 | | - |
504 | | - describe('resize', () => { |
505 | | - it('should not set overflow attribute when content has no scrollbar', () => { |
506 | | - expect(dialog.hasAttribute('overflow')).to.be.false; |
507 | | - expect(overlay.hasAttribute('overflow')).to.be.false; |
508 | | - }); |
509 | | - |
510 | | - it('should set overflow attribute when scrollbar appears on resize', async () => { |
511 | | - overlay.style.maxHeight = `${contentHeight}px`; |
512 | | - await nextResize(overlay); |
513 | | - expect(dialog.getAttribute('overflow')).to.equal('bottom'); |
514 | | - expect(overlay.getAttribute('overflow')).to.equal('bottom'); |
515 | | - }); |
516 | | - |
517 | | - it('should remove overflow attribute when header renderer is removed', async () => { |
518 | | - overlay.style.maxHeight = `${contentHeight + footerHeight}px`; |
519 | | - await nextResize(overlay); |
520 | | - expect(dialog.hasAttribute('overflow')).to.be.true; |
521 | | - expect(overlay.hasAttribute('overflow')).to.be.true; |
522 | | - |
523 | | - dialog.headerRenderer = null; |
524 | | - await nextUpdate(dialog); |
525 | | - expect(dialog.hasAttribute('overflow')).to.be.false; |
526 | | - expect(overlay.hasAttribute('overflow')).to.be.false; |
527 | | - }); |
528 | | - |
529 | | - it('should remove overflow attribute when footer renderer is removed', async () => { |
530 | | - overlay.style.maxHeight = `${contentHeight + headerHeight}px`; |
531 | | - await nextResize(overlay); |
532 | | - expect(dialog.hasAttribute('overflow')).to.be.true; |
533 | | - expect(overlay.hasAttribute('overflow')).to.be.true; |
534 | | - |
535 | | - dialog.footerRenderer = null; |
536 | | - await nextUpdate(dialog); |
537 | | - expect(dialog.hasAttribute('overflow')).to.be.false; |
538 | | - expect(overlay.hasAttribute('overflow')).to.be.false; |
539 | | - }); |
540 | | - |
541 | | - it('should set overflow attribute when header title property is set', async () => { |
542 | | - dialog.headerRenderer = null; |
543 | | - dialog.footerRenderer = null; |
544 | | - await nextUpdate(dialog); |
545 | | - |
546 | | - overlay.style.maxHeight = `${contentHeight}px`; |
547 | | - await nextResize(overlay); |
548 | | - expect(dialog.hasAttribute('overflow')).to.be.false; |
549 | | - expect(overlay.hasAttribute('overflow')).to.be.false; |
550 | | - |
551 | | - dialog.headerTitle = 'Title'; |
552 | | - await nextUpdate(dialog); |
553 | | - expect(dialog.getAttribute('overflow')).to.equal('bottom'); |
554 | | - expect(overlay.getAttribute('overflow')).to.equal('bottom'); |
555 | | - }); |
556 | | - |
557 | | - it('should remove overflow attribute when header title is removed', async () => { |
558 | | - dialog.headerRenderer = null; |
559 | | - dialog.footerRenderer = null; |
560 | | - dialog.headerTitle = 'Title'; |
561 | | - await nextUpdate(dialog); |
562 | | - |
563 | | - overlay.style.maxHeight = `${contentHeight}px`; |
564 | | - await nextResize(overlay); |
565 | | - expect(dialog.hasAttribute('overflow')).to.be.true; |
566 | | - expect(overlay.hasAttribute('overflow')).to.be.true; |
567 | | - |
568 | | - dialog.headerTitle = null; |
569 | | - await nextUpdate(dialog); |
570 | | - expect(dialog.hasAttribute('overflow')).to.be.false; |
571 | | - expect(overlay.hasAttribute('overflow')).to.be.false; |
572 | | - }); |
573 | | - |
574 | | - it('should remove overflow attribute if no header, footer or title is set', async () => { |
575 | | - dialog.headerTitle = 'Title'; |
576 | | - overlay.style.maxHeight = `${contentHeight}px`; |
577 | | - await nextResize(overlay); |
578 | | - |
579 | | - dialog.headerRenderer = null; |
580 | | - dialog.footerRenderer = null; |
581 | | - dialog.headerTitle = null; |
582 | | - await nextUpdate(dialog); |
583 | | - expect(dialog.hasAttribute('overflow')).to.be.false; |
584 | | - expect(overlay.hasAttribute('overflow')).to.be.false; |
585 | | - }); |
586 | | - }); |
587 | | - |
588 | | - describe('scroll', () => { |
589 | | - beforeEach(async () => { |
590 | | - dialog.renderer = createRenderer(Array(100).join('Lorem ipsum dolor sit amet\n')); |
591 | | - await nextUpdate(dialog); |
592 | | - }); |
593 | | - |
594 | | - it('should set overflow to "bottom" when scrollbar appears after re-render', () => { |
595 | | - expect(dialog.getAttribute('overflow')).to.equal('bottom'); |
596 | | - expect(overlay.getAttribute('overflow')).to.equal('bottom'); |
597 | | - }); |
598 | | - |
599 | | - it('should update overflow to "top bottom" on partial content scroll', () => { |
600 | | - content.scrollTop += 200; |
601 | | - content.dispatchEvent(new CustomEvent('scroll')); |
602 | | - |
603 | | - expect(dialog.getAttribute('overflow')).to.equal('top bottom'); |
604 | | - expect(overlay.getAttribute('overflow')).to.equal('top bottom'); |
605 | | - }); |
606 | | - |
607 | | - it('should update overflow to "top" when content is fully scrolled', () => { |
608 | | - content.scrollTop += content.scrollHeight - content.clientHeight; |
609 | | - content.dispatchEvent(new CustomEvent('scroll')); |
610 | | - |
611 | | - expect(dialog.getAttribute('overflow')).to.equal('top'); |
612 | | - expect(overlay.getAttribute('overflow')).to.equal('top'); |
613 | | - }); |
614 | | - }); |
615 | | - }); |
616 | 485 | }); |
617 | 486 |
|
618 | 487 | describe('renderer set before attach', () => { |
|
0 commit comments