@@ -0,0 +1,68 @@
|
||||
import { App } from '@inertiajs/react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { expect, test } from 'vitest';
|
||||
import Search from '@/pages/search/procurement';
|
||||
|
||||
test('process search separates result groups escapes text and retains page links', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<App
|
||||
initialComponent={Search}
|
||||
initialPage={{
|
||||
component: 'search/procurement',
|
||||
url: '/compras/pesquisa?q=QA',
|
||||
version: null,
|
||||
clearHistory: false,
|
||||
encryptHistory: true,
|
||||
props: {
|
||||
errors: {},
|
||||
term: 'QA',
|
||||
groups: [
|
||||
{
|
||||
key: 'requests',
|
||||
title: 'Requisições',
|
||||
records: {
|
||||
total: 16,
|
||||
current_page: 1,
|
||||
last_page: 2,
|
||||
prev_page_url: null,
|
||||
next_page_url:
|
||||
'/compras/pesquisa?q=QA&requests_page=2',
|
||||
data: [
|
||||
{
|
||||
id: 7,
|
||||
title: 'QA <original>',
|
||||
detail: 'draft',
|
||||
href: '/requisicoes/7',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
expect(html).toContain('QA <original>');
|
||||
expect(html).toContain('Rascunho');
|
||||
expect(html).toContain('q=QA&requests_page=2');
|
||||
expect(html).toContain('/requisicoes/7');
|
||||
expect(html).toContain('ainda não pesquisa Pessoas, facturas');
|
||||
});
|
||||
|
||||
test('empty search explains the minimum input rather than implying that the database is empty', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<App
|
||||
initialComponent={Search}
|
||||
initialPage={{
|
||||
component: 'search/procurement',
|
||||
url: '/compras/pesquisa',
|
||||
version: null,
|
||||
clearHistory: false,
|
||||
encryptHistory: true,
|
||||
props: { errors: {}, term: '', groups: [] },
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
expect(html).toContain('Introduza pelo menos dois caracteres');
|
||||
expect(html).not.toContain('Nenhum resultado no seu âmbito');
|
||||
});
|
||||
Reference in New Issue
Block a user