Skip to content

Commit

Permalink
Add some missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpens committed Jul 19, 2024
1 parent 21cfcbf commit 4425f7b
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"build:watch": "rollup -c --watch",
"clean": "rimraf dist/",
"lint": "tsc --project ./tsconfig.json --noEmit && tsc --noEmit --project ./tsconfig.test.json",
"test": "jest --verbose",
"test": "jest --verbose --coverage",
"watch:test": "jest --verbose --watch"
},
"main": "./dist/index.cjs.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/react/src/FieldSet/FieldSet.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ describe('FieldSet', () => {
expect(component).toHaveClass('ams-field-set__legend')
})

it('renders the error class', () => {
const { container } = render(<FieldSet legend="Test" invalid />)

const component = container.querySelector(':only-child')

expect(component).toHaveClass('ams-field-set--invalid')
})

it('supports ForwardRef in React', () => {
const ref = createRef<HTMLFieldSetElement>()

Expand Down
8 changes: 8 additions & 0 deletions packages/react/src/FormErrorList/FormErrorList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ describe('Form error list', () => {
describe('renders a custom document title label', () => {
const label = { plural: 'errors', singular: 'error' }

it('no errors', async () => {
document.title = docTitle

render(<FormErrorList errors={[]} />)

await waitFor(() => expect(document.title).toBe(docTitle))
})

it('single error', async () => {
document.title = docTitle

Expand Down
8 changes: 8 additions & 0 deletions packages/react/src/Image/Image.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ describe('Image', () => {
expect(component).toHaveClass('ams-image')
})

it('renders a class name to display the image as large as its container', () => {
const { container } = render(<Image cover />)

const component = container.querySelector(':only-child')

expect(component).toHaveClass('ams-image--cover')
})

it('supports ForwardRef in React', () => {
const ref = createRef<HTMLImageElement>()

Expand Down
8 changes: 8 additions & 0 deletions packages/react/src/PageMenu/PageMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ describe('Page menu', () => {
expect(component).toHaveClass('ams-page-menu--align-end')
})

it('renders a class name to prevent wrapping', () => {
const { container } = render(<PageMenu wrap={false} />)

const component = container.querySelector(':only-child')

expect(component).toHaveClass('ams-page-menu--no-wrap')
})

it('is able to pass a React ref', () => {
const ref = createRef<HTMLUListElement>()

Expand Down
8 changes: 8 additions & 0 deletions packages/react/src/Row/Row.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ describe('Row', () => {
expect(component).toHaveClass('ams-row extra')
})

it('renders a class name to allow wrapping', () => {
const { container } = render(<Row wrap />)

const component = container.querySelector(':only-child')

expect(component).toHaveClass('ams-row--wrap')
})

it('renders with an article tag', () => {
render(<Row as="article" />)

Expand Down
8 changes: 8 additions & 0 deletions packages/react/src/Screen/Screen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ describe('Screen', () => {
expect(component).toHaveClass('ams-screen--x-wide')
})

it('renders the full-height class name', () => {
const { container } = render(<Screen fullHeight />)

const component = container.querySelector(':only-child')

expect(component).toHaveClass('ams-screen--full-height')
})

it('renders an additional class name', () => {
const { container } = render(<Screen className="extra" />)

Expand Down

0 comments on commit 4425f7b

Please sign in to comment.