Files
portal/app/tests/Frontend/RefoundDeletedSources.spec.ts
T

28 lines
1.4 KiB
TypeScript
Raw Normal View History

import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import RefoundDeletedSources from '../../resources/js/views/autopodbor/screens/RefoundDeletedSources.vue';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const src = (id: number, identifier: string): any => ({ id, identifier, signal_type: 'site', box: 'archived' });
describe('RefoundDeletedSources — блок «ранее удалённые, вернуть?»', () => {
it('показывает ранее удалённые источники и кнопки «Вернуть»', () => {
const w = mount(RefoundDeletedSources, { props: { sources: [src(7, 'staroe.ru'), src(9, '79001112233')] } });
expect(w.text()).toContain('staroe.ru');
expect(w.text()).toContain('79001112233');
expect(w.text().toLowerCase()).toContain('ранее удал');
expect(w.findAll('button').length).toBe(2);
});
it('клик «Вернуть» шлёт событие restore с id источника', async () => {
const w = mount(RefoundDeletedSources, { props: { sources: [src(7, 'staroe.ru')] } });
await w.find('button').trigger('click');
expect(w.emitted('restore')?.[0]).toEqual([7]);
});
it('пусто → блок не рисуется', () => {
const w = mount(RefoundDeletedSources, { props: { sources: [] } });
expect(w.text().trim()).toBe('');
});
});