Skip to content

Commit

Permalink
chore(Button): add test and fix docs (#1556)
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker authored Sep 12, 2022
1 parent dde8576 commit a9177d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ showTabs: true

| Properties | Description |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `type` | _(optional)_ `button`, `reset` or `submit` for the `type` HTML attribute (default to `button`) . |
| `type` | _(optional)_ `button`, `reset` or `submit` for the `type` HTML attribute. Defaults to `button` for legacy reasons. |
| `text` or `children` | _(optional)_ the content of the button can be a string or a React Element. |
| `title` | _(optional)_ title of the button. Optional, but should always be included because of accessibility. |
| `variant` | _(optional)_ defines the kind of button. Possible values are `primary`, `secondary`, `tertiary` and `signal`. Defaults to `primary`. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ describe('Button component', () => {
expect(Comp.find('button').instance().hasAttribute('type')).toBe(false)
})

it('should use span element if defined', () => {
const Comp = mount(<Component element="span" />)
expect(Comp.find('.dnb-button').instance().tagName).toBe('SPAN')
expect(Comp.find('.dnb-button').instance().getAttribute('type')).toBe(
'button'
)
})

it('has "on_click" event which will trigger on a click', () => {
const my_event = jest.fn()
const myEvent = jest.fn()
Expand Down

0 comments on commit a9177d8

Please sign in to comment.