refactor [P-137]: убраны варнинги
This commit is contained in:
1 parent
bdce08fb73
commit
1a553dfa5e
4 files changed
+101
-3
No files matched your search
@@ -173,7 +173,6 @@ export default {
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.titles {
|
||||
font-family: cursive !important;
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import { mount } from '../../../../node_modules/@vue/test-utils';
|
||||
import CarouselList from '@/components/carousel-list.vue';
|
||||
|
||||
// Мок axios
|
||||
jest.mock('@/utils/axios-api', () => ({
|
||||
baseURL: 'http://example.com/',
|
||||
axiosApiInstance: {
|
||||
get: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
// Мок alert store
|
||||
jest.mock('@/store/useAlertStore', () => ({
|
||||
useAlertStore: () => ({
|
||||
alert: {
|
||||
alert: false,
|
||||
text: '',
|
||||
color: '',
|
||||
ico: '',
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
describe('CarouselList.vue', () => {
|
||||
beforeEach(() => {
|
||||
const { axiosApiInstance } = require('@/utils/axios-api');
|
||||
axiosApiInstance.get.mockClear();
|
||||
Object.defineProperty(document, 'exitFullscreen', {
|
||||
writable: true,
|
||||
value: jest.fn(),
|
||||
});
|
||||
});
|
||||
|
||||
it('вызывает axiosApiInstance.get при монтировании', async () => {
|
||||
const { axiosApiInstance } = require('@/utils/axios-api');
|
||||
axiosApiInstance.get.mockResolvedValue({ data: { mess: '', result: [] } });
|
||||
|
||||
const wrapper = mount(CarouselList, {
|
||||
global: {
|
||||
stubs: ['v-carousel', 'v-carousel-item'],
|
||||
},
|
||||
});
|
||||
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(axiosApiInstance.get).toHaveBeenCalledWith('api/navigation/carousels/');
|
||||
});
|
||||
|
||||
it('устанавливает большой интервал, если текущий слайд – видео', async () => {
|
||||
const wrapper = mount(CarouselList, {
|
||||
global: {
|
||||
stubs: ['v-carousel', 'v-carousel-item'],
|
||||
},
|
||||
});
|
||||
|
||||
// Создаём фейковый элемент видео
|
||||
wrapper.vm.videoElement = [{ pause: jest.fn(), currentSrc: '' }];
|
||||
|
||||
wrapper.vm.carous = [{ link: '/video.mp4' }];
|
||||
wrapper.vm.currentslide = 0;
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
wrapper.vm.slidechanged();
|
||||
expect(wrapper.vm.interval).toBe(10000000000);
|
||||
});
|
||||
|
||||
it('обрабатывает событие ended', async () => {
|
||||
const wrapper = mount(CarouselList, {
|
||||
global: {
|
||||
stubs: ['v-carousel', 'v-carousel-item'],
|
||||
},
|
||||
});
|
||||
|
||||
const fakeEvent = {
|
||||
target: {
|
||||
currentTime: 5,
|
||||
pause: jest.fn(),
|
||||
},
|
||||
};
|
||||
|
||||
wrapper.vm.ended(fakeEvent);
|
||||
expect(fakeEvent.target.currentTime).toBe(0);
|
||||
expect(fakeEvent.target.pause).toHaveBeenCalled();
|
||||
expect(document.exitFullscreen).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user