Skip to content

Commit

Permalink
test: add notification-bar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgoud committed Feb 15, 2024
1 parent a64e990 commit af7fb88
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions packages/components/notification-bar/test/notification-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('NotificationBar tests', () => {
) => {
wrapper = mount(PuikNotificationBar, {
props: {
messages: [{ text: 'Default message' }],
...propsData,
},
...options,
Expand All @@ -20,4 +21,57 @@ describe('NotificationBar tests', () => {
factory()
expect(wrapper).toBeTruthy()
})

it('should accept teleport prop', () => {
const teleport = { to: 'body', prepend: true }
factory({ teleport })
expect(wrapper.props().teleport).toEqual(teleport)
})

it('should accept variant prop', () => {
const variant = 'blue'
factory({ variant })
expect(wrapper.props().variant).toBe(variant)
})

it('should accept closable prop', () => {
const closable = true
factory({ closable })
expect(wrapper.props().closable).toBe(closable)
})

it('should accept messages prop', () => {
const messages = [
{
icon: 'info',
text: 'This is a test message',
link: { url: 'https://test.com', text: 'Test Link' },
},
]
factory({ messages })
expect(wrapper.props().messages).toEqual(messages)
})

it('should emit close event when close button is clicked', async () => {
factory({
closable: true,
messages: [{ text: 'This is a test message' }],
})
await wrapper.find('.notification-bar__close-button').trigger('click')
expect(wrapper.emitted()).toHaveProperty('close')
})

it('should have correct classes based on props', () => {
factory({
variant: 'blue',
closable: true,
messages: [{ text: 'This is a test message' }],
})
expect(wrapper.find('.notification-bar__container').classes()).toContain(
'notification-bar__container--blue'
)
expect(wrapper.find('.notification-bar__container').classes()).toContain(
'notification-bar__container--closable'
)
})
})

0 comments on commit af7fb88

Please sign in to comment.