Commit 9e7b65ed authored by Stefan Cameron's avatar Stefan Cameron

impl.extractNextType() improved and impl.checkWithArray() now using it

parent c99b6ec6
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -146,7 +146,7 @@ describe.only('module: lib/impl', function() { // DEBUG remove only
});
});
describe.only('#extractNextType()', function() { // DEBUG remove only
describe('#extractNextType()', function() { // DEBUG remove only
it('should use the specified qualifier unless a qualifier is found', function() {
let typeset = [qualifiers.EXPECTED, types.FUNCTION];
let nextType = impl.extractNextType(typeset, qualifiers.OPTIONAL);
......@@ -161,6 +161,14 @@ describe.only('module: lib/impl', function() { // DEBUG remove only
expect(nextType).to.eql([qualifiers.OPTIONAL, types.FUNCTION]);
});
it('should use the qualifier, if any, if qualifier=true', function() {
expect(impl.extractNextType([types.STRING], true)).to.eql([types.STRING]);
expect(impl.extractNextType([qualifiers.REQUIRED, types.STRING], true))
.to.eql([qualifiers.REQUIRED, types.STRING]);
expect(impl.extractNextType([qualifiers.REQUIRED, types.STRING], false))
.to.eql([types.STRING]);
});
it('should handle simple string types', function() {
let typeset = [types.STRING, types.FINITE];
let nextType = impl.extractNextType(typeset);
......@@ -256,20 +264,27 @@ describe.only('module: lib/impl', function() { // DEBUG remove only
expect(typeset).to.eql([]);
expect(nextType).to.eql([qualifiers.REQUIRED, val]);
typeset = [types.PLAIN_OBJECT, val];
typeset = [types.ANY, val];
nextType = impl.extractNextType(typeset);
expect(typeset).to.eql([val]);
expect(nextType).to.eql([types.PLAIN_OBJECT]);
expect(nextType).to.eql([types.ANY]);
nextType = impl.extractNextType(typeset);
expect(typeset).to.eql([]);
expect(nextType).to.eql([val]);
});
it('should allow an empty array as the typeset', function() {
expect(function() {
impl.extractNextType([]);
}).not.to.throw(/Invalid array typeset/);
expect(impl.extractNextType([])).to.eql([]);
});
});
describe('#check()', function() {
describe.only('#check()', function() { // DEBUG remove only
it('should return an RtvSuccess on successful validation', function() {
expect(impl.check(1, types.FINITE)).to.be.an.instanceof(RtvSuccess);
expect(impl.check(1, function() { return true; })).to.be.an.instanceof(RtvSuccess);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment