Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import deepEqual from 'deep-equal';
import * as fastCheck from 'fast-check';
import test from 'ava';
import queryString from '..';
// Valid query parameters must follow:
// - key can be any unicode string (not empty)
// - value must be one of:
// --> any unicode string
// --> null
// --> array containing values defined above (at least two items)
const queryParamsArbitrary = fastCheck.dictionary(
fastCheck.fullUnicodeString(1, 10),
fastCheck.oneof(
fastCheck.fullUnicodeString(),
fastCheck.constant(null),
fastCheck.array(fastCheck.oneof(fastCheck.fullUnicodeString(), fastCheck.constant(null)), 2, 10)
)
);
const optionsArbitrary = fastCheck.record({
arrayFormat: fastCheck.constantFrom('bracket', 'index', 'none'),
strict: fastCheck.boolean(),
encode: fastCheck.constant(true),
sort: fastCheck.constant(false)
}, {withDeletedKeys: true});
test('should read correctly from stringified query params', t => {
t.notThrows(() => {
fastCheck.assert(
fastCheck.property(
test('parse stringified object', () => {
const key = fc.fullUnicodeString()
const values = [
key,
fc.lorem(1000, false), // words
fc.lorem(100, true), // sentences
fc.boolean(),
fc.integer(),
fc.double(),
fc.constantFrom(null, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY)
]
const yamlArbitrary = fc.anything({ key: key, values: values })
const optionsArbitrary = fc.record(
{
keepBlobsInJSON: fc.boolean(),
keepCstNodes: fc.boolean(),
keepNodeTypes: fc.boolean(),
mapAsMap: fc.constant(false),
import deepEqual from 'deep-equal';
import * as fastCheck from 'fast-check';
import test from 'ava';
import queryString from '..';
// Valid query parameters must follow:
// - key can be any unicode string (not empty)
// - value must be one of:
// --> any unicode string
// --> null
// --> array containing values defined above (at least two items)
const queryParamsArbitrary = fastCheck.dictionary(
fastCheck.fullUnicodeString(1, 10),
fastCheck.oneof(
fastCheck.fullUnicodeString(),
fastCheck.constant(null),
fastCheck.array(fastCheck.oneof(fastCheck.fullUnicodeString(), fastCheck.constant(null)), 2, 10)
)
);
const optionsArbitrary = fastCheck.record({
arrayFormat: fastCheck.constantFrom('bracket', 'index', 'none'),
strict: fastCheck.boolean(),
encode: fastCheck.constant(true),
sort: fastCheck.constant(false)
}, {withDeletedKeys: true});
test('should read correctly from stringified query params', t => {
t.notThrows(() => {
it('/api/profile/:uid', async () =>
await fc.assert(
fc.asyncProperty(fc.fullUnicodeString(), async uid => {
await throwIfHttpFailed(httpGet(server, `/api/profile/${encodeURIComponent(uid)}`));
}),
{ timeout: 100 }
));
it('/api/comment', async () =>