mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
Update the nuxt3 version. Co-authored-by: Jonathan Adeline <jonathan@baserow.io> Co-authored-by: Bram Wiepjes <bramw@protonmail.com> Co-authored-by: Cezary <cezary@baserow.io> Co-authored-by: Tsering Paljor <tsering@baserow.io> Co-authored-by: Przemyslaw Kukulski <przemyslaw+gh@baserow.io> Co-authored-by: Bram <bram2w@users.noreply.github.com>
66 lines
1.5 KiB
JavaScript
66 lines
1.5 KiB
JavaScript
import { TestApp } from '@baserow/test/helpers/testApp'
|
|
import Rating from '@baserow/modules/database/components/Rating'
|
|
|
|
describe('Rating component', () => {
|
|
let testApp = null
|
|
|
|
beforeEach(() => {
|
|
testApp = new TestApp()
|
|
})
|
|
|
|
afterEach(() => {
|
|
testApp.afterEach()
|
|
})
|
|
|
|
const mountComponent = (
|
|
props = { value: 3, maxValue: 5, readOnly: true },
|
|
listeners = {}
|
|
) => {
|
|
return testApp.mount(Rating, { propsData: props, listeners })
|
|
}
|
|
|
|
const changeValue = async (wrapper, value) => {
|
|
const star = wrapper.find(`.rating :nth-child(${value})`)
|
|
|
|
await star.trigger('click')
|
|
}
|
|
|
|
test('Default rating component', async () => {
|
|
const wrapper = await mountComponent()
|
|
expect(wrapper.element).toMatchSnapshot()
|
|
})
|
|
|
|
test('Customized rating component', async () => {
|
|
const wrapper = await mountComponent({
|
|
value: 3,
|
|
maxValue: 5,
|
|
readOnly: false,
|
|
style: 'flag',
|
|
color: 'dark-blue',
|
|
})
|
|
expect(wrapper.element).toMatchSnapshot()
|
|
})
|
|
|
|
test('interactions with rating component', async () => {
|
|
const onUpdate = vi.fn()
|
|
const wrapper = await mountComponent(
|
|
{
|
|
value: 3,
|
|
maxValue: 5,
|
|
readOnly: false,
|
|
},
|
|
{ update: onUpdate }
|
|
)
|
|
|
|
changeValue(wrapper, 1)
|
|
expect(onUpdate).toHaveBeenCalledWith(1)
|
|
|
|
changeValue(wrapper, 5)
|
|
expect(onUpdate).toHaveBeenCalledWith(5)
|
|
|
|
// If we click on current value, should set value to 0
|
|
changeValue(wrapper, 3)
|
|
expect(onUpdate).toHaveBeenCalledWith(0)
|
|
})
|
|
})
|