Skip to content

Commit 95a9531

Browse files
committed
Try to add tests
1 parent b53096f commit 95a9531

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

addons/addon-search/test/SearchAddon.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,57 @@ test.describe('Search Tests', () => {
480480
]);
481481
});
482482
});
483+
484+
test.describe('Wrapped line search functionality', () => {
485+
test('should correctly count matches across multiple wrapped lines', async () => {
486+
await ctx.page.evaluate(`
487+
window.calls = [];
488+
window.search.onDidChangeResults(e => window.calls.push(e));
489+
`);
490+
491+
const content = 'a'.repeat(300);
492+
await ctx.proxy.write(content);
493+
strictEqual(await ctx.page.evaluate(`window.search.findNext('${content}', { decorations: { activeMatchColorOverviewRuler: '#ff0000', matchOverviewRuler: '#ffff00' } })`), true);
494+
deepStrictEqual(await ctx.page.evaluate('window.calls'), [
495+
{ resultCount: 1, resultIndex: 0 }
496+
]);
497+
});
498+
499+
test('should handle reverse search across wrapped lines', async () => {
500+
await ctx.page.evaluate(`
501+
window.calls = [];
502+
window.search.onDidChangeResults(e => window.calls.push(e));
503+
`);
504+
505+
const content = 'x'.repeat(300);
506+
await ctx.proxy.write(content);
507+
strictEqual(await ctx.page.evaluate(`window.search.findPrevious('${content}', { decorations: { activeMatchColorOverviewRuler: '#ff0000', matchOverviewRuler: '#ffff00' } })`), true);
508+
deepStrictEqual(await ctx.page.evaluate('window.calls'), [
509+
{ resultCount: 1, resultIndex: 0 }
510+
]);
511+
});
512+
513+
test('should update counts when content changes across wrapped lines', async () => {
514+
await ctx.page.evaluate(`
515+
window.calls = [];
516+
window.search.onDidChangeResults(e => window.calls.push(e));
517+
`);
518+
519+
const content = 'z'.repeat(300);
520+
await ctx.proxy.write(content);
521+
strictEqual(await ctx.page.evaluate(`window.search.findNext('${content}', { decorations: { activeMatchColorOverviewRuler: '#ff0000', matchOverviewRuler: '#ffff00' } })`), true);
522+
deepStrictEqual(await ctx.page.evaluate('window.calls'), [
523+
{ resultCount: 1, resultIndex: 0 }
524+
]);
525+
526+
await ctx.proxy.write('\\n\\r' + content);
527+
await timeout(300);
528+
deepStrictEqual(await ctx.page.evaluate('window.calls'), [
529+
{ resultCount: 1, resultIndex: 0 },
530+
{ resultCount: 2, resultIndex: 0 }
531+
]);
532+
});
533+
});
483534
});
484535

485536
function makeData(length: number): string {

0 commit comments

Comments
 (0)