forked from jquense/yup
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: lazy validator basic tests (jquense#366)
- Loading branch information
1 parent
41d23d6
commit b0b4869
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |