-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: worksofliam <[email protected]>
- Loading branch information
1 parent
4dc7e3a
commit 1c2bbc6
Showing
6 changed files
with
108 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { parseFilter } from '../../Filter'; | ||
import { Search } from '../../Search'; | ||
import { getConnection } from '../state'; | ||
|
||
describe('Search Tests', {concurrent: true}, () => { | ||
it('Single member search', async () => { | ||
const result = await Search.searchMembers(getConnection(), "QSYSINC", "QRPGLESRC", "IBM", "CMRPG"); | ||
expect(result.term).toBe("IBM"); | ||
expect(result.hits.length).toBe(1); | ||
const [hit] = result.hits; | ||
expect(hit.lines.length).toBe(3); | ||
|
||
const checkLine = (index: number, expectedNumber: number) => { | ||
expect(hit.lines[index].number).toBe(expectedNumber); | ||
expect(hit.lines[index].content).toContain(result.term); | ||
} | ||
|
||
checkLine(0, 7); | ||
checkLine(1, 11); | ||
checkLine(2, 13); | ||
}); | ||
|
||
it('Generic name search', async () => { | ||
const memberFilter = "E*"; | ||
const filter = parseFilter(memberFilter); | ||
const result = await Search.searchMembers(getConnection(), "QSYSINC", "QRPGLESRC", "IBM", memberFilter); | ||
expect(result.hits.every(hit => filter.test(hit.path.split("/").at(-1)!))).toBe(true); | ||
expect(result.hits.every(hit => !hit.path.endsWith(`MBR`))).toBe(true); | ||
}); | ||
|
||
it('Filtered members list search', async () => { | ||
const library = "QSYSINC"; | ||
const sourceFile = "QRPGLESRC"; | ||
const memberFilter = "S*,T*"; | ||
const filter = parseFilter(memberFilter); | ||
const checkNames = (names: string[]) => names.every(filter.test); | ||
|
||
const members = await getConnection().getContent().getMemberList({ library, sourceFile, members: memberFilter }); | ||
expect(checkNames(members.map(member => member.name))).toBe(true); | ||
|
||
const result = await Search.searchMembers(getConnection(), "QSYSINC", "QRPGLESRC", "SQL", members); | ||
expect(result.hits.length).toBe(6); | ||
expect(checkNames(result.hits.map(hit => hit.path.split("/").at(-1)!))).toBe(true); | ||
expect(result.hits.every(hit => !hit.path.endsWith(`MBR`))).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.