mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
fb711b4d4a
* fix: when payload type is 'json' validate value on toggle variable validation * test: add missing feature toggle creation with variant type json Ref https://github.com/Unleash/unleash/pull/1704#discussion_r896476042 * refractor: remove verbose comment on validateJsonString Ref https://github.com/Unleash/unleash/pull/1704#discussion_r896482210 * test: add missing feature toggle creation with variant type string Ref https://github.com/Unleash/unleash/pull/1704#discussion_r896476042 * refractor: move variant value joi validation Ref https://github.com/Unleash/unleash/pull/1704#discussion_r896478563
23 lines
801 B
TypeScript
23 lines
801 B
TypeScript
import { validateJsonString } from './validateJsonString';
|
|
|
|
test('should return true for valid json string', () => {
|
|
const input = '{"test":1,"nested":[{"test1":{"testinner":true}}]}';
|
|
expect(validateJsonString(input)).toBe(true);
|
|
});
|
|
|
|
test('should return false for invalid json string (missing starting {)', () => {
|
|
// missing starting {
|
|
const input = '"test":1,"nested":[{"test1":{"testinner":true}}]}';
|
|
expect(validateJsonString(input)).toBe(false);
|
|
});
|
|
|
|
test('should return false for invalid json string (plain string)', () => {
|
|
const input = 'not a json';
|
|
expect(validateJsonString(input)).toBe(false);
|
|
});
|
|
|
|
test('should return false for invalid json string (null as a string)', () => {
|
|
const input = 'null';
|
|
expect(validateJsonString(input)).toBe(false);
|
|
});
|