Skip to content

Commit

Permalink
text fixed in test file highlighted result
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleysmithTTD committed Dec 12, 2024
1 parent 872711e commit 4123220
Showing 1 changed file with 5 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,25 @@ const createResult = (text: string, indices: [number, number][]) => {
describe('Highlighted results', () => {
test('When there are no highlighted sections, it renders the full text', () => {
const result = createResult('Test site', []);
render(
<HighlightedResult
result={result}
resultText={`${result.item.name} (Site ID ${result.item.id})`}
/>
);
render(<HighlightedResult result={result} resultText={result.item.name} />);
expect(screen.getByText('Test site')).toBeInTheDocument();
});
test('When there is a highlighted section in the middle, it splits the sections up', () => {
const result = createResult('Test site', [[2, 3]]);
render(
<HighlightedResult
result={result}
resultText={`${result.item.name} (Site ID ${result.item.id})`}
/>
);
render(<HighlightedResult result={result} resultText={result.item.name} />);
expect(screen.getByText('Te')).toBeInTheDocument();
expect(screen.getByText('st')).toBeInTheDocument();
expect(screen.getByText('site')).toBeInTheDocument();
});
test('When there is a highlighted section at the start, it creates two sections', () => {
const result = createResult('Test site', [[0, 3]]);
render(
<HighlightedResult
result={result}
resultText={`${result.item.name} (Site ID ${result.item.id})`}
/>
);
render(<HighlightedResult result={result} resultText={result.item.name} />);
expect(screen.getByText('Test')).toBeInTheDocument();
expect(screen.getByText('site')).toBeInTheDocument();
});
test('When there is a highlighted section at the end, it creates two sections', () => {
const result = createResult('Test site', [[5, 8]]);
render(
<HighlightedResult
result={result}
resultText={`${result.item.name} (Site ID ${result.item.id})`}
/>
);
render(<HighlightedResult result={result} resultText={result.item.name} />);
expect(screen.getByText('Test')).toBeInTheDocument();
expect(screen.getByText('site')).toBeInTheDocument();
});
Expand All @@ -78,12 +58,7 @@ describe('Highlighted results', () => {
[0, 1],
[6, 8],
]);
render(
<HighlightedResult
result={result}
resultText={`${result.item.name} (Site ID ${result.item.id})`}
/>
);
render(<HighlightedResult result={result} resultText={result.item.name} />);
expect(screen.getByText('Te')).toBeInTheDocument();
expect(screen.getByText('st s')).toBeInTheDocument();
expect(screen.getByText('ite')).toBeInTheDocument();
Expand Down

0 comments on commit 4123220

Please sign in to comment.