-
Notifications
You must be signed in to change notification settings - Fork 2
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 #286 from social-native/feat/robust-value-transforms
Leverage suggested value literal transforms for more kinds of filter values
- Loading branch information
Showing
18 changed files
with
18,557 additions
and
8,302 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
4 changes: 2 additions & 2 deletions
4
__tests__/integration/__snapshots__/input_union_type.integration.test.ts.snap
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,44 @@ | ||
import {coerceStringValue} from '../../src/coerce_string_value'; | ||
|
||
describe('coerceStringValue', function() { | ||
it('coerces boolean strings', function() { | ||
const tests: Array<[string, boolean]> = [ | ||
['true', true], | ||
['TRUE', true], | ||
['false', false], | ||
['FALSE', false] | ||
]; | ||
|
||
for (const [input, expectedOutput] of tests) { | ||
expect(coerceStringValue(input)).toEqual(expectedOutput); | ||
} | ||
}); | ||
|
||
it('does not use auto trimming to coerce string to number', function() { | ||
expect(coerceStringValue('1.24 cows')).toEqual('1.24 cows'); | ||
}); | ||
|
||
it('ignores empty strings', function() { | ||
expect(coerceStringValue('')).toEqual(''); | ||
}); | ||
|
||
it('coerces float strings', function() { | ||
expect(coerceStringValue('1.22334')).toEqual(1.22334); | ||
}); | ||
|
||
it('coerces int strings', function() { | ||
expect(coerceStringValue('5')).toEqual(5); | ||
}); | ||
|
||
it('coerces null strings', function() { | ||
for (const input of ['NULL', 'null', 'nUlL']) { | ||
expect(coerceStringValue(input)).toBeNull(); | ||
} | ||
}); | ||
|
||
it('preserves strings that are not coercible', function() { | ||
const preserved = 'This is a really long sentence.'; | ||
|
||
expect(coerceStringValue(preserved)).toEqual(preserved); | ||
}); | ||
}); |
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.