-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Jest + make the search more robust
- Loading branch information
Showing
10 changed files
with
1,894 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
modulePathIgnorePatterns: ['<rootDir>/dist/'], | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
setupFiles: ['<rootDir>/testSetupFile.ts'] | ||
}; |
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,27 @@ | ||
import { searchKeywords } from './searchKeywords'; | ||
|
||
describe('searchKeywords', () => { | ||
test('match single word', () => { | ||
expect(searchKeywords('quick', 'quickly')).toBe(true); | ||
}); | ||
|
||
test('match multiple words in correct order', () => { | ||
expect(searchKeywords('quick br', 'quick brown fox')).toBe(true); | ||
}); | ||
|
||
test('match multiple words in different order', () => { | ||
expect(searchKeywords('fox quick', 'quick brown fox')).toBe(true); | ||
}); | ||
|
||
test('two partial words', () => { | ||
expect(searchKeywords('qu fo', 'quick brown fox')).toBe(true); | ||
}); | ||
|
||
test('NO match multiple words', () => { | ||
expect(searchKeywords('bear', 'quick brown fox')).toBe(false); | ||
}); | ||
|
||
test('NO match multiple search terms', () => { | ||
expect(searchKeywords('brown bear', 'quick brown fox')).toBe(false); | ||
}); | ||
}); |
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,6 @@ | ||
export function searchKeywords(search: string, keywords: string): boolean { | ||
return new RegExp( | ||
'(?=.*?\\b' + search.split(' ').join(')(?=.*?\\b') + ').*', | ||
'i' | ||
).test(keywords); | ||
} |
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,15 @@ | ||
import dotenvFlow from 'dotenv-flow'; | ||
|
||
declare module 'dotenv-flow' { | ||
interface DotenvConfigOptions { | ||
/** | ||
* With this option you can suppress all the console outputs except errors and deprecation warnings. | ||
*/ | ||
silent?: boolean; | ||
} | ||
} | ||
|
||
dotenvFlow.config({ | ||
default_node_env: 'test', | ||
silent: true | ||
}); |
Oops, something went wrong.