58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
|
import { describe, it, expect } from 'vitest';
|
||
|
import { mount } from '@vue/test-utils';
|
||
|
import VProgressBar from '../src/components/progressbar/VProgressBar.vue';
|
||
|
|
||
|
describe('VProgressBar', () => {
|
||
|
it('renders with default props', () => {
|
||
|
const wrapper = mount(VProgressBar);
|
||
|
const progressBar = wrapper.findComponent({ name: 'ProgressBar' });
|
||
|
|
||
|
expect(progressBar.exists()).toBe(true);
|
||
|
expect(progressBar.props('value')).toBe(0);
|
||
|
expect(progressBar.props('mode')).toBe('determinate');
|
||
|
expect(progressBar.props('showValue')).toBe(false);
|
||
|
});
|
||
|
|
||
|
it('renders with custom value', () => {
|
||
|
const wrapper = mount(VProgressBar, {
|
||
|
props: { value: 75 }
|
||
|
});
|
||
|
|
||
|
expect(wrapper.findComponent({ name: 'ProgressBar' }).props('value')).toBe(75);
|
||
|
});
|
||
|
|
||
|
it('renders in indeterminate mode', () => {
|
||
|
const wrapper = mount(VProgressBar, {
|
||
|
props: { indeterminate: true, value: 75 }
|
||
|
});
|
||
|
|
||
|
expect(wrapper.findComponent({ name: 'ProgressBar' }).props('mode')).toBe('indeterminate');
|
||
|
});
|
||
|
|
||
|
it('hides value when small is true even if showValue is true', () => {
|
||
|
const wrapper = mount(VProgressBar, {
|
||
|
props: { showValue: true, small: true, value: 25 }
|
||
|
});
|
||
|
|
||
|
expect(wrapper.findComponent({ name: 'ProgressBar' }).props('showValue')).toBe(false);
|
||
|
});
|
||
|
|
||
|
it('applies small class when small is true', () => {
|
||
|
const wrapper = mount(VProgressBar, {
|
||
|
props: { small: true, value: 15 }
|
||
|
});
|
||
|
|
||
|
expect(wrapper.find('.p-progressbar').classes()).toContain('small');
|
||
|
});
|
||
|
|
||
|
it('renders slot content', () => {
|
||
|
const wrapper = mount(VProgressBar, {
|
||
|
props: { value: 43, showValue: true },
|
||
|
slots: {
|
||
|
default: 'Valeur: 43/100'
|
||
|
}
|
||
|
});
|
||
|
expect(wrapper.html()).toContain('Valeur: 43/100');
|
||
|
});
|
||
|
});
|