* Makes InstallationRouter like others * Adds testing for Range file requests - Fixes issue with small requests (0-2) * Revert "Makes InstallationRouter like others" This reverts commit e2d2a16ebf2757db6138c7b5b33c97c56c69ead6. * Better handling of errors in FilesRouter * Fix incorrectness in range requests * Better/simpler logic * Only on mongo at it requires Gridstore * Open file streaming to all adapters supporting it * Improves coverage of parsers * Ensures depreciation warning is effective * Removes unused function * de-duplicate logic * Removes necessity of overriding req.params.className on subclasses routers * Use babel-preset-env to ensure min-version compatible code * removes dead code * Leverage indexes in order to infer which field is duplicated upon signup - A note mentioned that it would be possible to leverage using the indexes on username/email to infer which is duplicated * Small nit * Better template to match column name * Restores original implementation for safety * nits
68 lines
2.1 KiB
JavaScript
68 lines
2.1 KiB
JavaScript
import {
|
|
numberParser,
|
|
numberOrBoolParser,
|
|
booleanParser,
|
|
objectParser,
|
|
arrayParser,
|
|
moduleOrObjectParser,
|
|
nullParser,
|
|
} from '../src/cli/utils/parsers';
|
|
|
|
describe('parsers', () => {
|
|
it('parses correctly with numberParser', () => {
|
|
const parser = numberParser('key');
|
|
expect(parser(2)).toEqual(2);
|
|
expect(parser('2')).toEqual(2);
|
|
expect(() => {parser('string')}).toThrow();
|
|
});
|
|
|
|
it('parses correctly with numberOrBoolParser', () => {
|
|
const parser = numberOrBoolParser('key');
|
|
expect(parser(true)).toEqual(true);
|
|
expect(parser(false)).toEqual(false);
|
|
expect(parser('true')).toEqual(true);
|
|
expect(parser('false')).toEqual(false);
|
|
expect(parser(1)).toEqual(1);
|
|
expect(parser('1')).toEqual(1);
|
|
});
|
|
|
|
it('parses correctly with booleanParser', () => {
|
|
const parser = booleanParser;
|
|
expect(parser(true)).toEqual(true);
|
|
expect(parser(false)).toEqual(false);
|
|
expect(parser('true')).toEqual(true);
|
|
expect(parser('false')).toEqual(false);
|
|
expect(parser(1)).toEqual(true);
|
|
expect(parser(2)).toEqual(false);
|
|
});
|
|
|
|
it('parses correctly with objectParser', () => {
|
|
const parser = objectParser;
|
|
expect(parser({hello: 'world'})).toEqual({hello: 'world'});
|
|
expect(parser('{"hello": "world"}')).toEqual({hello: 'world'});
|
|
expect(() => {parser('string')}).toThrow();
|
|
});
|
|
|
|
it('parses correctly with moduleOrObjectParser', () => {
|
|
const parser = moduleOrObjectParser;
|
|
expect(parser({hello: 'world'})).toEqual({hello: 'world'});
|
|
expect(parser('{"hello": "world"}')).toEqual({hello: 'world'});
|
|
expect(parser('string')).toEqual('string');
|
|
});
|
|
|
|
it('parses correctly with arrayParser', () => {
|
|
const parser = arrayParser;
|
|
expect(parser([1,2,3])).toEqual([1,2,3]);
|
|
expect(parser('{"hello": "world"}')).toEqual(['{"hello": "world"}']);
|
|
expect(parser('1,2,3')).toEqual(['1','2','3']);
|
|
expect(() => {parser(1)}).toThrow();
|
|
});
|
|
|
|
it('parses correctly with nullParser', () => {
|
|
const parser = nullParser;
|
|
expect(parser('null')).toEqual(null);
|
|
expect(parser(1)).toEqual(1);
|
|
expect(parser('blabla')).toEqual('blabla');
|
|
});
|
|
});
|