Skip to content

Commit 8be086d

Browse files
committed
test(primitives): update tests for Popover component
1 parent 8ca790d commit 8be086d

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

packages/primitives/src/components/popover/popover.cy.tsx

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,72 @@ describe('Popover', () => {
515515
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.prop', 'tagName').should('eq', 'DIV');
516516
});
517517

518+
it('should be <h1> element when level="1"', () => {
519+
cy.mount(
520+
<Popover.Root>
521+
<Popover.Content>
522+
<Popover.Title level="1" data-testid={POPOVER_TITLE_TESTID} />
523+
</Popover.Content>
524+
</Popover.Root>
525+
);
526+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.prop', 'tagName').should('eq', 'H1');
527+
});
528+
529+
it('should be <h2> element when level="2"', () => {
530+
cy.mount(
531+
<Popover.Root>
532+
<Popover.Content>
533+
<Popover.Title level="2" data-testid={POPOVER_TITLE_TESTID} />
534+
</Popover.Content>
535+
</Popover.Root>
536+
);
537+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.prop', 'tagName').should('eq', 'H2');
538+
});
539+
540+
it('should be <h3> element when level="3"', () => {
541+
cy.mount(
542+
<Popover.Root>
543+
<Popover.Content>
544+
<Popover.Title level="3" data-testid={POPOVER_TITLE_TESTID} />
545+
</Popover.Content>
546+
</Popover.Root>
547+
);
548+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.prop', 'tagName').should('eq', 'H3');
549+
});
550+
551+
it('should be <h4> element when level="4"', () => {
552+
cy.mount(
553+
<Popover.Root>
554+
<Popover.Content>
555+
<Popover.Title level="4" data-testid={POPOVER_TITLE_TESTID} />
556+
</Popover.Content>
557+
</Popover.Root>
558+
);
559+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.prop', 'tagName').should('eq', 'H4');
560+
});
561+
562+
it('should be <h5> element when level="5"', () => {
563+
cy.mount(
564+
<Popover.Root>
565+
<Popover.Content>
566+
<Popover.Title level="5" data-testid={POPOVER_TITLE_TESTID} />
567+
</Popover.Content>
568+
</Popover.Root>
569+
);
570+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.prop', 'tagName').should('eq', 'H5');
571+
});
572+
573+
it('should be <h6> element when level="6"', () => {
574+
cy.mount(
575+
<Popover.Root>
576+
<Popover.Content>
577+
<Popover.Title level="6" data-testid={POPOVER_TITLE_TESTID} />
578+
</Popover.Content>
579+
</Popover.Root>
580+
);
581+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.prop', 'tagName').should('eq', 'H6');
582+
});
583+
518584
it('should contain passed children', () => {
519585
const POPOVER_TITLE_TEXT = 'POPOVER_TITLE_TEXT';
520586
cy.mount(
@@ -560,6 +626,72 @@ describe('Popover', () => {
560626
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.attr', 'data-part', 'title');
561627
});
562628

629+
it('should have attribute data-lavel with value "1" when level="1"', () => {
630+
cy.mount(
631+
<Popover.Root>
632+
<Popover.Content>
633+
<Popover.Title level="1" data-testid={POPOVER_TITLE_TESTID} />
634+
</Popover.Content>
635+
</Popover.Root>
636+
);
637+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.attr', 'data-level', '1');
638+
});
639+
640+
it('should have attribute data-lavel with value "2" when level="2"', () => {
641+
cy.mount(
642+
<Popover.Root>
643+
<Popover.Content>
644+
<Popover.Title level="2" data-testid={POPOVER_TITLE_TESTID} />
645+
</Popover.Content>
646+
</Popover.Root>
647+
);
648+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.attr', 'data-level', '2');
649+
});
650+
651+
it('should have attribute data-lavel with value "3" when level="3"', () => {
652+
cy.mount(
653+
<Popover.Root>
654+
<Popover.Content>
655+
<Popover.Title level="3" data-testid={POPOVER_TITLE_TESTID} />
656+
</Popover.Content>
657+
</Popover.Root>
658+
);
659+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.attr', 'data-level', '3');
660+
});
661+
662+
it('should have attribute data-lavel with value "4" when level="4"', () => {
663+
cy.mount(
664+
<Popover.Root>
665+
<Popover.Content>
666+
<Popover.Title level="4" data-testid={POPOVER_TITLE_TESTID} />
667+
</Popover.Content>
668+
</Popover.Root>
669+
);
670+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.attr', 'data-level', '4');
671+
});
672+
673+
it('should have attribute data-lavel with value "5" when level="5"', () => {
674+
cy.mount(
675+
<Popover.Root>
676+
<Popover.Content>
677+
<Popover.Title level="5" data-testid={POPOVER_TITLE_TESTID} />
678+
</Popover.Content>
679+
</Popover.Root>
680+
);
681+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.attr', 'data-level', '5');
682+
});
683+
684+
it('should have attribute data-lavel with value "6" when level="6"', () => {
685+
cy.mount(
686+
<Popover.Root>
687+
<Popover.Content>
688+
<Popover.Title level="6" data-testid={POPOVER_TITLE_TESTID} />
689+
</Popover.Content>
690+
</Popover.Root>
691+
);
692+
cy.get(`[data-testid="${POPOVER_TITLE_TESTID}"]`).should('have.attr', 'data-level', '6');
693+
});
694+
563695
it('should have attribute id with unique value when not provided via id prop', () => {
564696
cy.mount(
565697
<Popover.Root>

0 commit comments

Comments
 (0)