Skip to content

Commit

Permalink
WIP(ui-breadcrumb,ui-test-utils): update
Browse files Browse the repository at this point in the history
  • Loading branch information
balzss committed Oct 5, 2023
1 parent 689e505 commit 87b2bc7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
53 changes: 26 additions & 27 deletions packages/ui-breadcrumb/src/Breadcrumb/__tests__/Breadcrumb.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,41 @@
* SOFTWARE.
*/

// import React from 'react'
import React from 'react'

// import { expect, mount, generateA11yTests } from '@instructure/ui-test-utils'
import { generateA11yTests } from '@instructure/ui-test-utils'
import { expect, mount, generateA11yTests } from '@instructure/ui-test-utils'

import { Breadcrumb } from '../index'
// import { BreadcrumbLocator } from '../BreadcrumbLocator'
import { BreadcrumbLocator } from '../BreadcrumbLocator'
import BreadcrumbExamples from '../__examples__/Breadcrumb.examples'

describe('<Breadcrumb />', async () => {
// it('should render the label as an aria-label attribute', async () => {
// await mount(
// <Breadcrumb label="Settings">
// <Breadcrumb.Link>Account</Breadcrumb.Link>
// </Breadcrumb>
// )
// const breadcrumb = await BreadcrumbLocator.find()
// const label = await breadcrumb.find(':label(Settings)')
//
// expect(label.getAttribute('aria-label')).to.equal('Settings')
// })
it('should render the label as an aria-label attribute', async () => {
await mount(
<Breadcrumb label="Settings">
<Breadcrumb.Link>Account</Breadcrumb.Link>
</Breadcrumb>
)
const breadcrumb = await BreadcrumbLocator.find()
const label = await breadcrumb.find(':label(Settings)')

expect(label.getAttribute('aria-label')).to.equal('Settings')
})

describe('with generated examples', async () => {
generateA11yTests(Breadcrumb, BreadcrumbExamples)
})

// it('should render an icon as a separator', async () => {
// await mount(
// <Breadcrumb label="Settings">
// <Breadcrumb.Link href="#">Account</Breadcrumb.Link>
// <Breadcrumb.Link>Settings</Breadcrumb.Link>
// </Breadcrumb>
// )
// const breadcrumb = await BreadcrumbLocator.find()
// const icon = await breadcrumb.find('svg')
//
// expect(icon.getAttribute('aria-hidden')).to.equal('true')
// })
it('should render an icon as a separator', async () => {
await mount(
<Breadcrumb label="Settings">
<Breadcrumb.Link href="#">Account</Breadcrumb.Link>
<Breadcrumb.Link>Settings</Breadcrumb.Link>
</Breadcrumb>
)
const breadcrumb = await BreadcrumbLocator.find()
const icon = await breadcrumb.find('svg')

expect(icon.getAttribute('aria-hidden')).to.equal('true')
})
})
5 changes: 2 additions & 3 deletions packages/ui-test-utils/src/utils/generateComponentExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* SOFTWARE.
*/

// import { nanoid } from 'nanoid'
import { nanoid } from 'nanoid'

import { generatePropCombinations } from './generatePropCombinations'
import React, { ComponentType, ReactNode } from 'react'
Expand Down Expand Up @@ -241,8 +241,7 @@ export function generateComponentExamples<Props extends Record<string, any>>(
}
const propsString = fastSerialize(componentProps)
if (!PROPS_CACHE.includes(propsString)) {
// const key = nanoid()
const key = '' + Math.round(Math.random() * 10000)
const key = nanoid()
const exampleProps = getExampleProps(props)
exampleCount++
if (exampleCount < maxExamples) {
Expand Down

0 comments on commit 87b2bc7

Please sign in to comment.