Skip to content

Instantly share code, notes, and snippets.

@andrei-cacio
Last active June 13, 2016 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrei-cacio/df8f720d290abd47eb17d15c248fbe8b to your computer and use it in GitHub Desktop.
Save andrei-cacio/df8f720d290abd47eb17d15c248fbe8b to your computer and use it in GitHub Desktop.
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