Skip to content

Commit

Permalink
Added test, updated .min
Browse files Browse the repository at this point in the history
  • Loading branch information
fergaldoyle committed Oct 26, 2015
1 parent 809335a commit 095678d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-form",
"version": "0.1.3",
"version": "0.1.4",
"description": "Form validation for Vue.js",
"main": "vue-form.js",
"authors": ["Fergal Doyle"],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-form",
"version": "0.1.3",
"version": "0.1.4",
"description": "Form validation for Vue.js",
"main": "vue-form.js",
"scripts": {
Expand Down
24 changes: 24 additions & 0 deletions test/specs/vue-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('vue-form', function () {
<input v-model="model.k" v-form-ctrl name="k" type="number" max="10" />
<input v-model="model.l" v-form-ctrl name="l" type="url" />
<input v-model="model.m" v-form-ctrl name="m" type="text" :pattern="'[A-Za-z]{3}'" />
<input v-model="model.n" v-form-ctrl name="n" type="email" required minlength="8" />
<input v-model="model.o" v-form-ctrl name="o" type="text" custom-validator="customValidator" />
<input type="checkbox" value="Jack" v-model="multicheck" v-form-ctrl required name="multicheck"/>
Expand All @@ -44,6 +45,7 @@ describe('vue-form', function () {
k: 5,
l: 'non url',
m: 'x',
n: '',
o: 'abc',
multicheck: []
}
Expand Down Expand Up @@ -178,6 +180,28 @@ describe('vue-form', function () {
Vue.nextTick(done);
});
});

it('should validate multiple validators', function (done) {
expect(vm.myform.n.$valid).toBe(false);
// pass required
vm.model.n = 'abc';
Vue.nextTick(function () {
// email will be invalid
expect(vm.myform.n.$valid).toBe(false);
// pass email
vm.model.n = '[email protected]';
Vue.nextTick(function () {
// minlength will be invalid
expect(vm.myform.n.$valid).toBe(false);
// pass minlength
vm.model.n = '[email protected]';
Vue.nextTick(function () {
expect(vm.myform.n.$valid).toBe(true);
Vue.nextTick(done);
});
});
});
});

it('should validate custom-validator', function (done) {
expect(vm.myform.o.$valid).toBe(false);
Expand Down
2 changes: 1 addition & 1 deletion vue-form.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 095678d

Please sign in to comment.