Last active
June 13, 2016 07:45
-
-
Save andrei-cacio/df8f720d290abd47eb17d15c248fbe8b to your computer and use it in GitHub Desktop.
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
import { assert } from 'chai'; | |
import proxyquire from 'proxyquire'; | |
import { getJquerySpies, getJquery } from '../src/jquery-getter'; | |
const $ = getJquery(); | |
const getValidator = proxyquire('../src/validator', { jquery : $ }).default; | |
const isEmpty = proxyquire('../src/validator', { jquery : $ }).isEmpty; | |
const addClassFn = getJquerySpies().addClass; | |
describe('validator', () => { | |
it('should add the error class when validation fails', () => { | |
let value = ''; | |
const validator = getValidator(isEmpty, 'input', () => value); | |
validator.validate(); | |
assert.isTrue(addClassFn.called); | |
assert.isTrue(addClassFn.getCall(0).calledWith('error')); | |
addClassFn.reset(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment