Skip to content

Commit

Permalink
Add validateOn validation to FieldSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
flut1 committed Aug 2, 2016
1 parent ec762d7 commit 9f6c120
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions test/unit/field/FieldSpec.ts
@@ -1,7 +1,30 @@
import * as chai from 'chai';
import KnockoutValidator from "../../../src/lib/KnockoutValidator";
import Field from "../../../src/lib/fields/Field";
import * as ko from 'knockout';
const {expect} = chai;

// describe('Field', () =>
// {
//
// });
describe('Field', () =>
{
describe('with validateOn prop of "value"', () =>
{
const testValidator = new KnockoutValidator();
const testField = new Field('test', null);
testField.name = 'testField';
testField.validator = testValidator;
testField.validateOn = 'value';
testField.value = ko.observable('');
testField.rule = /^[0-9]+$/;

it('should set the isValid state of the field to true after passing a valid value', done =>
{
testField.value('328492');
ko.tasks.schedule(() =>
{
expect(testField.isValid()).to.equal(true);
done();
});
});
});

});

0 comments on commit 9f6c120

Please sign in to comment.