Skip to content

Commit

Permalink
feat(ui/testing): add QToolbar & QToolbarTitle test files
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Apr 22, 2024
1 parent 12748be commit 6a3f916
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
45 changes: 45 additions & 0 deletions ui/src/components/toolbar/QToolbar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { mount, flushPromises } from '@vue/test-utils'
import { describe, test, expect } from 'vitest'

import QToolbar from './QToolbar.js'

describe('[QToolbar API]', () => {
describe('[Props]', () => {
describe('[(prop)inset]', () => {
test('is defined correctly', () => {
expect(QToolbar.props.inset).toBeDefined()
})

test('type Boolean has effect', async () => {
const wrapper = mount(QToolbar)
const target = wrapper.get('.q-toolbar')

expect(
target.classes()
).not.toContain('q-toolbar--inset')

await wrapper.setProps({ inset: true })
await flushPromises()

expect(
target.classes()
).toContain('q-toolbar--inset')
})
})
})

describe('[Slots]', () => {
describe('[(slot)default]', () => {
test('renders the content', () => {
const slotContent = 'some-slot-content'
const wrapper = mount(QToolbar, {
slots: {
default: () => slotContent
}
})

expect(wrapper.html()).toContain(slotContent)
})
})
})
})
45 changes: 45 additions & 0 deletions ui/src/components/toolbar/QToolbarTitle.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { mount, flushPromises } from '@vue/test-utils'
import { describe, test, expect } from 'vitest'

import QToolbarTitle from './QToolbarTitle.js'

describe('[QToolbarTitle API]', () => {
describe('[Props]', () => {
describe('[(prop)shrink]', () => {
test('is defined correctly', () => {
expect(QToolbarTitle.props.shrink).toBeDefined()
})

test('type Boolean has effect', async () => {
const wrapper = mount(QToolbarTitle)
const target = wrapper.get('.q-toolbar__title')

expect(
target.classes()
).not.toContain('col-shrink')

await wrapper.setProps({ shrink: true })
await flushPromises()

expect(
target.classes()
).toContain('col-shrink')
})
})
})

describe('[Slots]', () => {
describe('[(slot)default]', () => {
test('renders the content', () => {
const slotContent = 'some-slot-content'
const wrapper = mount(QToolbarTitle, {
slots: {
default: () => slotContent
}
})

expect(wrapper.html()).toContain(slotContent)
})
})
})
})

0 comments on commit 6a3f916

Please sign in to comment.