mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
- New badge UI, including editor. - Adds config to enable/disable badges. --------- Co-authored-by: Sebastian Stein <sebastian@codepassion.de> Co-authored-by: Maximilian Harz <maxharz@gmail.com>
77 lines
1.8 KiB
JavaScript
77 lines
1.8 KiB
JavaScript
import { render, screen, fireEvent } from '@testing-library/vue'
|
|
import BadgeSelection from './BadgeSelection.vue'
|
|
|
|
const localVue = global.localVue
|
|
|
|
describe('Badges.vue', () => {
|
|
const Wrapper = (propsData) => {
|
|
return render(BadgeSelection, {
|
|
propsData,
|
|
localVue,
|
|
})
|
|
}
|
|
|
|
describe('without badges', () => {
|
|
it('renders', () => {
|
|
const wrapper = Wrapper({ badges: [] })
|
|
expect(wrapper.container).toMatchSnapshot()
|
|
})
|
|
})
|
|
|
|
describe('with badges', () => {
|
|
const badges = [
|
|
{
|
|
id: '1',
|
|
icon: '/path/to/some/icon',
|
|
isDefault: false,
|
|
description: 'Some description',
|
|
},
|
|
{
|
|
id: '2',
|
|
icon: '/path/to/another/icon',
|
|
isDefault: true,
|
|
description: 'Another description',
|
|
},
|
|
{
|
|
id: '3',
|
|
icon: '/path/to/third/icon',
|
|
isDefault: false,
|
|
description: 'Third description',
|
|
},
|
|
]
|
|
|
|
let wrapper
|
|
|
|
beforeEach(() => {
|
|
wrapper = Wrapper({ badges })
|
|
})
|
|
|
|
it('renders', () => {
|
|
expect(wrapper.container).toMatchSnapshot()
|
|
})
|
|
|
|
describe('clicking on a badge', () => {
|
|
beforeEach(async () => {
|
|
const badge = screen.getByText(badges[1].description)
|
|
await fireEvent.click(badge)
|
|
})
|
|
|
|
it('emits badge-selected with badge', async () => {
|
|
expect(wrapper.emitted()['badge-selected']).toEqual([[badges[1]]])
|
|
})
|
|
})
|
|
|
|
describe('clicking twice on a badge', () => {
|
|
beforeEach(async () => {
|
|
const badge = screen.getByText(badges[1].description)
|
|
await fireEvent.click(badge)
|
|
await fireEvent.click(badge)
|
|
})
|
|
|
|
it('emits badge-selected with null', async () => {
|
|
expect(wrapper.emitted()['badge-selected']).toEqual([[badges[1]], [null]])
|
|
})
|
|
})
|
|
})
|
|
})
|