|
|
@@ -3,6 +3,27 @@ import {format} from '@e22m4u/js-format';
|
|
|
import {validateProjectionSchema} from './validate-projection-schema.js';
|
|
|
|
|
|
describe('validateProjectionSchema', function () {
|
|
|
+ it('should require the "schema" argument to be a valid value', function () {
|
|
|
+ const throwable = v => () => validateProjectionSchema(v);
|
|
|
+ const error = s =>
|
|
|
+ format(
|
|
|
+ 'Projection schema must be an Object, a Function ' +
|
|
|
+ 'or a non-empty String, but %s was given.',
|
|
|
+ s,
|
|
|
+ );
|
|
|
+ expect(throwable('')).to.throw(error('""'));
|
|
|
+ expect(throwable(10)).to.throw(error('10'));
|
|
|
+ expect(throwable(0)).to.throw(error('0'));
|
|
|
+ expect(throwable(true)).to.throw(error('true'));
|
|
|
+ expect(throwable(false)).to.throw(error('false'));
|
|
|
+ expect(throwable([])).to.throw(error('Array'));
|
|
|
+ expect(throwable(undefined)).to.throw(error('undefined'));
|
|
|
+ expect(throwable(null)).to.throw(error('null'));
|
|
|
+ throwable('str')();
|
|
|
+ throwable({})();
|
|
|
+ throwable(() => ({}))();
|
|
|
+ });
|
|
|
+
|
|
|
it('should require the "shallowMode" argument to be a Boolean', function () {
|
|
|
const throwable = v => () => validateProjectionSchema({}, v);
|
|
|
const error = s =>
|
|
|
@@ -49,27 +70,6 @@ describe('validateProjectionSchema', function () {
|
|
|
validateProjectionSchema(schema, false, validatedSchemas);
|
|
|
});
|
|
|
|
|
|
- it('should require the "schema" argument to be a valid value', function () {
|
|
|
- const throwable = v => () => validateProjectionSchema(v);
|
|
|
- const error = s =>
|
|
|
- format(
|
|
|
- 'Projection schema must be an Object, a Function ' +
|
|
|
- 'or a non-empty String, but %s was given.',
|
|
|
- s,
|
|
|
- );
|
|
|
- expect(throwable('')).to.throw(error('""'));
|
|
|
- expect(throwable(10)).to.throw(error('10'));
|
|
|
- expect(throwable(0)).to.throw(error('0'));
|
|
|
- expect(throwable(true)).to.throw(error('true'));
|
|
|
- expect(throwable(false)).to.throw(error('false'));
|
|
|
- expect(throwable([])).to.throw(error('Array'));
|
|
|
- expect(throwable(undefined)).to.throw(error('undefined'));
|
|
|
- expect(throwable(null)).to.throw(error('null'));
|
|
|
- throwable('str')();
|
|
|
- throwable({})();
|
|
|
- throwable(() => ({}))();
|
|
|
- });
|
|
|
-
|
|
|
it('should require property options to be an object or a boolean', function () {
|
|
|
const throwable = v => () => validateProjectionSchema({foo: v});
|
|
|
const error = s =>
|