diff --git a/sources/__tests__/accessible-name.js b/sources/__tests__/accessible-name.js index c1973bb9..5d4d2527 100644 --- a/sources/__tests__/accessible-name.js +++ b/sources/__tests__/accessible-name.js @@ -40,6 +40,92 @@ expect.extend({ } }); +function testMarkup(markup, accessibleName) { + const container = renderIntoDocument(markup); + + const testNode = container.querySelector("[data-test]"); + expect(testNode).toHaveAccessibleName(accessibleName); +} + +describe("to upstream", () => { + test.each([ + // name from content + [ + "cell", + `
greek alpha
`, + "greek alpha" + ], + [ + "checkbox", + `
greek beta
`, + "greek beta" + ], + [ + "columnheader", + `
greek gamma
`, + "greek gamma" + ], + [ + "gridcell", + `
greek delta
`, + "greek delta" + ], + [ + "legend", + `
greek zeta
`, + "greek zeta" + ], + [ + "menuitem", + `
  • greek eta
  • `, + "greek eta" + ], + [ + "menuitemradio", + `
  • greek theta
  • `, + "greek theta" + ], + [ + "menuitemcheckbox", + `
  • greek iota
  • `, + "greek iota" + ], + [ + "radio", + `
    greek kappa
    `, + "greek kappa" + ], + [ + "row", + `
    greeklambda
    `, + "greek lambda" + ], + [ + "rowheader", + `
    greek mu
    `, + "greek mu" + ], + [ + "switch", + `
    greek nu
    `, + "greek nu" + ], + ["tab", `
    greek xi
    `, "greek xi"], + [ + "tooltip", + `
    greek omicron
    `, + "greek omicron" + ], + [ + "treeitem", + `
  • greek pi
  • `, + "greek pi" + ] + ])(`role %s`, (_, markup, expectedAccessibleName) => + testMarkup(markup, expectedAccessibleName) + ); +}); + test.each([ [ ` @@ -108,8 +194,7 @@ test.each([ `, "This is a test" - ], - // byAltText('an image') = byRole('image', {name: 'an image'}) + ], // byAltText('an image') = byRole('image', {name: 'an image'}) [`an image`, "an image"], // this would require a custom matcher [ @@ -125,9 +210,4 @@ test.each([ [`