Skip to content

Commit

Permalink
test: lazy validator basic tests (jquense#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-graf authored and jquense committed Nov 14, 2018
1 parent 41d23d6 commit b0b4869
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/lazy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { lazy, mixed } from '../src';

describe('lazy', function() {
it('should throw on a non-schema value', () => {
(() => lazy(() => undefined).validate()).should.throw();
});

describe('mapper', () => {
const value = 1;
let mapper;

beforeEach(() => {
mapper = sinon.stub();
mapper.returns(mixed());
});

it('should call with value', () => {
lazy(mapper).validate(value);
mapper.should.have.been.calledWith(value);
});

it('should call with context', () => {
const context = {
a: 1,
};
lazy(mapper).validate(value, context);
mapper.should.have.been.calledWithExactly(value, context);
});
});
});

0 comments on commit b0b4869

Please sign in to comment.