-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5220124
commit be4ae89
Showing
11 changed files
with
345 additions
and
144 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
37 changes: 17 additions & 20 deletions
37
frontend/src/views/game/__tests__/is-search-match.test.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,58 @@ | ||
import isSearchMatch from '../is-search-match'; | ||
import { searchLogic } from '../is-search-match'; | ||
|
||
describe('Search Match logic', () => { | ||
it('Should be a match if there is no search (as everything matches)', () => { | ||
expect(isSearchMatch('One little piggy', 'Bob Dylan', '', false)).toBe( | ||
true | ||
); | ||
expect(searchLogic('One little piggy', 'Bob Dylan', '', false)).toBe(true); | ||
}); | ||
|
||
it('Should not be a match if the post is blurred', () => { | ||
expect(isSearchMatch('One little piggy', 'Bob Dylan', 'little', true)).toBe( | ||
expect(searchLogic('One little piggy', 'Bob Dylan', 'little', true)).toBe( | ||
false | ||
); | ||
}); | ||
|
||
it('Should be a match if the search matches the content', () => { | ||
expect( | ||
isSearchMatch('One little piggy', 'Bob Dylan', 'little', false) | ||
).toBe(true); | ||
expect(searchLogic('One little piggy', 'Bob Dylan', 'little', false)).toBe( | ||
true | ||
); | ||
|
||
expect( | ||
isSearchMatch('One little piggy', 'Bob Dylan', 'LITTLE', false) | ||
).toBe(true); | ||
expect(searchLogic('One little piggy', 'Bob Dylan', 'LITTLE', false)).toBe( | ||
true | ||
); | ||
}); | ||
|
||
it('Should NOT be a match if the search does not matches the content', () => { | ||
expect(isSearchMatch('One little piggy', 'Bob Dylan', 'big', false)).toBe( | ||
expect(searchLogic('One little piggy', 'Bob Dylan', 'big', false)).toBe( | ||
false | ||
); | ||
|
||
expect(isSearchMatch('One little piggy', 'Bob Dylan', 'litle', false)).toBe( | ||
expect(searchLogic('One little piggy', 'Bob Dylan', 'litle', false)).toBe( | ||
false | ||
); | ||
}); | ||
|
||
it('Should be a match if the search matches the author', () => { | ||
expect(isSearchMatch('One little piggy', 'Bob Dylan', 'dyl', false)).toBe( | ||
expect(searchLogic('One little piggy', 'Bob Dylan', 'dyl', false)).toBe( | ||
true | ||
); | ||
|
||
expect(isSearchMatch('One little piggy', 'Bob Dylan', 'bob d', false)).toBe( | ||
expect(searchLogic('One little piggy', 'Bob Dylan', 'bob d', false)).toBe( | ||
true | ||
); | ||
}); | ||
|
||
it('Should NOT be a match if the search does not matches the author', () => { | ||
expect(isSearchMatch('One little piggy', 'Bob Dylan', 'John', false)).toBe( | ||
expect(searchLogic('One little piggy', 'Bob Dylan', 'John', false)).toBe( | ||
false | ||
); | ||
|
||
expect(isSearchMatch('One little piggy', 'Bob Dylan', 'Lenon', false)).toBe( | ||
expect(searchLogic('One little piggy', 'Bob Dylan', 'Lenon', false)).toBe( | ||
false | ||
); | ||
}); | ||
|
||
it('Should NOT be a match if the author is null', () => { | ||
expect(isSearchMatch('One little piggy', null, 'John', false)).toBe(false); | ||
|
||
expect(isSearchMatch('One little piggy', null, 'Lenon', false)).toBe(false); | ||
expect(searchLogic('One little piggy', null, 'John', false)).toBe(false); | ||
expect(searchLogic('One little piggy', null, 'Lenon', false)).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
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
Oops, something went wrong.