From 7d2bdacf77ba0258bd0e8f5cc18c4855a93a4a89 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Tue, 11 Sep 2018 15:48:24 -0700 Subject: [PATCH] Added test case for when regex and case sensitive are both selected --- src/addons/search/search.test.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/addons/search/search.test.ts b/src/addons/search/search.test.ts index 56dd0d67..a96f7d01 100644 --- a/src/addons/search/search.test.ts +++ b/src/addons/search/search.test.ts @@ -134,5 +134,30 @@ describe('search addon', () => { expect(hello1).eql(undefined); expect(hello2).eql({col: 8, row: 2, term: 'Hello'}); }); + it('should respect case sensitive + regex', function(): void { + search.apply(MockTerminal); + const term = new MockTerminal({cols: 20, rows: 4}); + term.core.write('hellohello\r\nHelloHello'); + term.pushWriteData(); + + /** + * hellohello + * HelloHello + */ + + const searchOptions = { + regex: true, + wholeWord: false, + caseSensitive: true + }; + const hello0 = (term.searchHelper as any)._findInLine('Hello', 0, searchOptions); + const hello1 = (term.searchHelper as any)._findInLine('Hello$', 0, searchOptions); + const hello2 = (term.searchHelper as any)._findInLine('Hello', 1, searchOptions); + const hello3 = (term.searchHelper as any)._findInLine('Hello$', 1, searchOptions); + expect(hello0).eql(undefined); + expect(hello1).eql(undefined); + expect(hello2).eql({col: 0, row: 1, term: 'Hello'}); + expect(hello3).eql({col: 5, row: 1, term: 'Hello'}); + }); }); });