-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: PouchStorageTable using incorrect $ne operator (#2011)
Resolves #1505 Changes: - Modified `PouchFilter` type to use $ne instead of $neq - Modified `$regex` prop to be able to accept `RegExp` and `string`, rather than just string by default Steps Moving Forward: - Code change is implemented, having difficulty with imports when trying to run Unit Tests (did not commit the file yet)
- Loading branch information
1 parent
95a589c
commit 6cf1240
Showing
3 changed files
with
47 additions
and
19 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,29 @@ | ||
import { makePouchFilter } from './PouchStorageTable'; | ||
|
||
describe('PouchStorageTable - Filter Functions', () => { | ||
describe('makePouchFilter', () => { | ||
it.each([ | ||
['eq', 'value', { $eq: 'value' }], | ||
['notEq', 'value', { $ne: 'value' }], | ||
['greaterThan', 'value', { $gt: 'value' }], | ||
['greaterThanOrEqualTo', 'value', { $gte: 'value' }], | ||
['lessThan', 'value', { $lt: 'value' }], | ||
['lessThanOrEqualTo', 'value', { $lte: 'value' }], | ||
['startsWith', 'val', { $regex: `/^val.*/` }], | ||
['contains', 'value', { $regex: '/value/' }], | ||
['inIgnoreCase', ['value1', 'value2'], { $regex: '/value1,value2/i' }], | ||
])( | ||
'should create a PouchFilter for %s operator', | ||
(type, value, expected) => { | ||
const filter = makePouchFilter(type, value); | ||
expect(filter).toEqual(expected); | ||
} | ||
); | ||
|
||
it('should throw an error for unsupported filter types', () => { | ||
expect(() => makePouchFilter('unsupported', 'value')).toThrow( | ||
'Unsupported type: unsupported' | ||
); | ||
}); | ||
}); | ||
}); |
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