Files
interview-demo-code/frontend/spa/tests/unit/components/Price.test.js

46 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import Price from '@/components/Price.vue';
describe('Price.vue', () => {
it('должен отображать цену с символом рубля', () => {
const wrapper = mount(Price, {
props: {
value: 1000,
},
});
expect(wrapper.text()).toContain('₽');
expect(wrapper.text()).toContain('1 000');
});
it('должен использовать значение по умолчанию 0', () => {
const wrapper = mount(Price, {
props: {},
});
expect(wrapper.text()).toContain('₽');
});
it('должен форматировать большие числа', () => {
const wrapper = mount(Price, {
props: {
value: 1234567,
},
});
expect(wrapper.text()).toContain('1 234 567');
});
it('должен обрабатывать нулевое значение', () => {
const wrapper = mount(Price, {
props: {
value: 0,
},
});
expect(wrapper.text()).toContain('₽');
});
});