-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2609 from KaelenProctor/feature/tag-filter-partia…
…l-match Change tag filter to be partial matching instead of exact
- Loading branch information
Showing
4 changed files
with
146 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { setElementOperation } from '../../src/client/filtering/FuncOperations'; | ||
|
||
describe('setElementOperation', () => { | ||
it('Invalid operator', async () => { | ||
const result = () => setElementOperation('+=', 'Tag'); | ||
expect(result).toThrow(Error); | ||
expect(result).toThrow('Unrecognized operator'); | ||
}); | ||
|
||
it('Equality operator matching', async () => { | ||
//Predicate values are lowercased by the nearley grammar | ||
const filterer = setElementOperation('=', 'fetch'); | ||
|
||
//The filter function for tags lowercases the inputs | ||
const tags = ['brazen', 'Fetch', 'Kindred']; | ||
expect(filterer(tags)).toBeTruthy(); | ||
}); | ||
|
||
it('Equality operator NOT matching', async () => { | ||
//Predicate values are lowercased by the nearley grammar | ||
const filterer = setElementOperation('=', 'travel'); | ||
|
||
//The filter function for tags lowercases the inputs | ||
const tags = ['brazen', 'Fetch', 'Kindred']; | ||
expect(filterer(tags)).toBeFalsy(); | ||
}); | ||
|
||
it('Contains operator matching', async () => { | ||
//Predicate values are lowercased by the nearley grammar | ||
const filterer = setElementOperation(':', 'fetch'); | ||
|
||
//The filter function for tags lowercases the inputs | ||
const tags = ['brazen', 'Fetch Land', 'Kindred']; | ||
expect(filterer(tags)).toBeTruthy(); | ||
}); | ||
|
||
it('Contains operator NOT matching', async () => { | ||
//Predicate values are lowercased by the nearley grammar | ||
const filterer = setElementOperation(':', 'rap'); | ||
|
||
//The filter function for tags lowercases the inputs | ||
const tags = ['brazen', 'Fetch Land', 'Kindred']; | ||
expect(filterer(tags)).toBeFalsy(); | ||
}); | ||
|
||
it.each(['!=', '<>'])('Inequality operator matching (%s)', async (op) => { | ||
//Predicate values are lowercased by the nearley grammar | ||
const filterer = setElementOperation(op, 'fetch'); | ||
|
||
//The filter function for tags lowercases the inputs | ||
const tags = ['brazen', 'Fetch', 'Kindred']; | ||
expect(filterer(tags)).toBeFalsy(); | ||
}); | ||
|
||
it.each(['!=', '<>'])('Inequality operator NOT matching (%s)', async (op) => { | ||
//Predicate values are lowercased by the nearley grammar | ||
const filterer = setElementOperation(op, 'transit'); | ||
|
||
//The filter function for tags lowercases the inputs | ||
const tags = ['brazen', 'Fetch', 'Kindred']; | ||
expect(filterer(tags)).toBeTruthy(); | ||
}); | ||
}); |
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