Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khiga8 committed Jul 17, 2023
1 parent 1aa7815 commit c97235c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tests/utils/get-role.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,27 @@ describe('getRole', function () {
expect(getRole({}, node)).to.equal('link')
})

it('returns link role for <Foo> with polymorphic prop set to "a" and href', function () {
it('returns link role for <Foo> with polymorphic prop set to "a" and conditional href', function () {
const node = mockJSXOpeningElement('Foo', [
mockJSXAttribute('as', 'a'),
[mockJSXConditionalAttribute('href', 'getUrl', '#', 'https://github.com/')],
mockJSXConditionalAttribute('href', 'getUrl', '#', 'https://github.com/'),
])
expect(getRole({}, node)).to.equal('link')
})

it('returns link role for <Foo> with polymorphic prop set to "a" and literal href', function () {
const node = mockJSXOpeningElement('Foo', [
mockJSXAttribute('as', 'a'),
mockJSXAttribute('href', 'https://github.com/'),
])
expect(getRole({}, node)).to.equal('link')
})

it('returns generic role for <Foo> with polymorphic prop set to "a" and no href', function () {
const node = mockJSXOpeningElement('Foo', [mockJSXAttribute('as', 'a')])
expect(getRole({}, node)).to.equal('generic')
})

it('returns region role for <section> with aria-label', function () {
const node = mockJSXOpeningElement('section', [mockJSXAttribute('aria-label', 'something')])
expect(getRole({}, node)).to.equal('region')
Expand Down

0 comments on commit c97235c

Please sign in to comment.