11import { expect , html } from '@open-wc/testing' ;
22import { createFixture } from '@patternfly/pfe-tools/test/create-fixture.js' ;
33import { PfHint } from '@patternfly/elements/pf-hint/pf-hint.js' ;
4+ import { a11ySnapshot } from '@patternfly/pfe-tools/test/a11y-snapshot.js' ;
45
56describe ( '<pf-hint>' , function ( ) {
67 describe ( 'simply instantiating' , function ( ) {
@@ -26,27 +27,11 @@ describe('<pf-hint>', function() {
2627 element = await createFixture < PfHint > ( html `
2728 < pf-hint > Welcome to the new documentation experience.</ pf-hint >
2829 ` ) ;
29- await element . updateComplete ;
30- } ) ;
31-
32- it ( 'should render body content' , function ( ) {
33- const body = element . shadowRoot ! . querySelector ( '#body' ) ;
34- expect ( body ) . to . exist ;
35- } ) ;
36-
37- it ( 'should not render title when not provided' , function ( ) {
38- const title = element . shadowRoot ! . querySelector ( '#title' ) ;
39- expect ( title ) . to . not . exist ;
40- } ) ;
41-
42- it ( 'should not render footer when not provided' , function ( ) {
43- const footer = element . shadowRoot ! . querySelector ( '#footer' ) ;
44- expect ( footer ) . to . not . exist ;
4530 } ) ;
4631
47- it ( 'should not render actions when not provided' , function ( ) {
48- const actions = element . shadowRoot ! . querySelector ( '#actions' ) ;
49- expect ( actions ) . to . not . exist ;
32+ it ( 'should render body content, and not title footer, or actions' , async function ( ) {
33+ const snap = await a11ySnapshot ( ) ;
34+ expect ( snap . children ?. length ) . to . equal ( 1 ) ;
5035 } ) ;
5136 } ) ;
5237
@@ -62,14 +47,9 @@ describe('<pf-hint>', function() {
6247 await element . updateComplete ;
6348 } ) ;
6449
65- it ( 'should render title' , function ( ) {
66- const title = element . shadowRoot ! . querySelector ( '#title' ) ;
67- expect ( title ) . to . exist ;
68- } ) ;
69-
70- it ( 'should render body content' , function ( ) {
71- const body = element . shadowRoot ! . querySelector ( '#body' ) ;
72- expect ( body ) . to . exist ;
50+ it ( 'should render title and body content' , async function ( ) {
51+ const snap = await a11ySnapshot ( ) ;
52+ expect ( snap . children ?. length ) . to . equal ( 2 ) ;
7353 } ) ;
7454 } ) ;
7555
@@ -105,14 +85,12 @@ describe('<pf-hint>', function() {
10585 await element . updateComplete ;
10686 } ) ;
10787
108- it ( 'should render actions' , function ( ) {
109- const actions = element . shadowRoot ! . querySelector ( '#actions' ) ;
110- expect ( actions ) . to . exist ;
111- } ) ;
112-
113- it ( 'should add has-actions class to container' , function ( ) {
114- const container = element . shadowRoot ! . querySelector ( '#container' ) ;
115- expect ( container ?. classList . contains ( 'has-actions' ) ) . to . be . true ;
88+ it ( 'should render title, body, and actions' , async function ( ) {
89+ const { children : [ actions , title , body , ...rest ] = [ ] } = await a11ySnapshot ( ) ;
90+ expect ( actions . role ) . to . equal ( 'button' ) ;
91+ expect ( title . role ) . to . equal ( 'text' ) ;
92+ expect ( body . role ) . to . equal ( 'text' ) ;
93+ expect ( rest . length ) . to . equal ( 0 ) ;
11694 } ) ;
11795 } ) ;
11896} ) ;
0 commit comments