Skip to content

Commit c97235c

Browse files
committed
Add tests
1 parent 1aa7815 commit c97235c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/utils/get-role.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,27 @@ describe('getRole', function () {
4646
expect(getRole({}, node)).to.equal('link')
4747
})
4848

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

57+
it('returns link role for <Foo> with polymorphic prop set to "a" and literal href', function () {
58+
const node = mockJSXOpeningElement('Foo', [
59+
mockJSXAttribute('as', 'a'),
60+
mockJSXAttribute('href', 'https://github.com/'),
61+
])
62+
expect(getRole({}, node)).to.equal('link')
63+
})
64+
65+
it('returns generic role for <Foo> with polymorphic prop set to "a" and no href', function () {
66+
const node = mockJSXOpeningElement('Foo', [mockJSXAttribute('as', 'a')])
67+
expect(getRole({}, node)).to.equal('generic')
68+
})
69+
5770
it('returns region role for <section> with aria-label', function () {
5871
const node = mockJSXOpeningElement('section', [mockJSXAttribute('aria-label', 'something')])
5972
expect(getRole({}, node)).to.equal('region')

0 commit comments

Comments
 (0)