Max ba0cc147e7
fix(webapp): fix admin badges settings (#8438)
* Remove proxy from nuxt.config, instead add proxy filter

* Show message when there are no badges
2025-04-26 17:25:27 +00:00

62 lines
1.2 KiB
JavaScript

import { render, fireEvent, screen } from '@testing-library/vue'
import BadgesSection from './BadgesSection.vue'
const localVue = global.localVue
const badge1 = {
id: 'badge1',
icon: 'icon1',
type: 'type1',
description: 'description1',
isActive: true,
}
const badge2 = {
id: 'badge2',
icon: 'icon2',
type: 'type1',
description: 'description2',
isActive: false,
}
describe('Admin/BadgesSection', () => {
let wrapper
const Wrapper = (withBadges = true) => {
return render(BadgesSection, {
localVue,
propsData: {
badges: withBadges ? [badge1, badge2] : [],
},
mocks: {
$t: jest.fn((t) => t),
},
})
}
describe('without badges', () => {
beforeEach(() => {
wrapper = Wrapper(false)
})
it('renders', () => {
expect(wrapper.baseElement).toMatchSnapshot()
})
})
describe('with badges', () => {
beforeEach(() => {
wrapper = Wrapper(true)
})
it('renders', () => {
expect(wrapper.baseElement).toMatchSnapshot()
})
it('emits toggleButton', async () => {
const button = screen.getByAltText(badge1.description)
await fireEvent.click(button)
expect(wrapper.emitted().toggleBadge[0][0]).toEqual(badge1)
})
})
})