Skip to content

Commit

Permalink
test: update to many test to check optional attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel-bijaoui committed Sep 6, 2016
1 parent 2e5e16b commit ebf3f01
Show file tree
Hide file tree
Showing 20 changed files with 250 additions and 246 deletions.
20 changes: 12 additions & 8 deletions test/unit/specs/fields/fieldCheckbox.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";

import Vue from "vue";
import FieldCheckbox from "src/fields/fieldCheckbox.vue";
Expand All @@ -18,7 +18,8 @@ describe("FieldCheckbox.vue", function() {
let schema = {
type: "checkbox",
label: "Status",
model: "status"
model: "status",
autocomplete: "off"
};
let model = { status: true };
let input;
Expand All @@ -34,7 +35,7 @@ describe("FieldCheckbox.vue", function() {

expect(input).to.be.defined;
expect(input.type).to.be.equal("checkbox");
expect(input.disabled).to.be.false;
// expect(input.disabled).to.be.false;
});

it("should contain the value", (done) => {
Expand All @@ -44,11 +45,14 @@ describe("FieldCheckbox.vue", function() {
});
});

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
done();
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete", "disabled"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});

Expand Down
8 changes: 0 additions & 8 deletions test/unit/specs/fields/fieldChecklist.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ describe("fieldChecklist.vue", function() {
expect(isChecked(6)).to.be.true;
});

/*it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(listbox.disabled).to.be.true;
done();
});
});*/

it("listbox value should be the model value after changed", (done) => {
model.skills = ["ReactJS"];
vm.$nextTick( () => {
Expand Down
32 changes: 13 additions & 19 deletions test/unit/specs/fields/fieldCleave.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";

import Vue from "vue";
import FieldCleave from "src/fields/fieldCleave.vue";
Expand All @@ -19,8 +19,9 @@ describe("fieldCleave.vue", function() {
type: "masked",
label: "Phone",
model: "phone",
autocomplete: "off",
placeholder: "",
readonly: false,
placeholder: "Field placeholder",
cleaveOptions: {
phone: true,
phoneRegionCode: "HU",
Expand All @@ -41,9 +42,9 @@ describe("fieldCleave.vue", function() {
expect(input).to.be.defined;
expect(input.type).to.be.equal("text");
expect(input.classList.contains("form-control")).to.be.true;
expect(input.placeholder).to.be.equal(schema.placeholder);
expect(input.readOnly).to.be.false;
expect(input.disabled).to.be.false;
// expect(input.placeholder).to.be.equal(schema.placeholder);
// expect(input.readOnly).to.be.false;
// expect(input.disabled).to.be.false;
});

it("should contain the value", (done) => {
Expand All @@ -53,21 +54,14 @@ describe("fieldCleave.vue", function() {
});
});

it("should set readOnly", (done) => {
schema.readonly = true;
vm.$nextTick( () => {
expect(input.readOnly).to.be.true;
schema.readonly = false;
done();
});
});
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete", "disabled", "readonly"];

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
field.disabled = false;
done();
attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});

Expand Down
20 changes: 12 additions & 8 deletions test/unit/specs/fields/fieldColor.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";

import Vue from "vue";
import FieldColor from "src/fields/fieldColor.vue";
Expand All @@ -18,7 +18,8 @@ describe("fieldColor.vue", function() {
let schema = {
type: "color",
label: "Color",
model: "color"
model: "color",
autocomplete: "off"
};
let model = { color: "#ff8822" };
let input;
Expand All @@ -35,7 +36,7 @@ describe("fieldColor.vue", function() {
expect(input).to.be.defined;
expect(input.type).to.be.equal("color");
//expect(input.classList.contains("form-control")).to.be.true;
expect(input.disabled).to.be.false;
// expect(input.disabled).to.be.false;
});

it("should contain the value", (done) => {
Expand All @@ -45,11 +46,14 @@ describe("fieldColor.vue", function() {
});
});

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
done();
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete"];

attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});

Expand Down
21 changes: 11 additions & 10 deletions test/unit/specs/fields/fieldDateTime.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";
import moment from "moment";

import Vue from "vue";
Expand All @@ -19,7 +19,10 @@ describe("fieldDateTime.vue", function() {
let schema = {
type: "dateTime",
label: "Event",
model: "event"
model: "event",
autocomplete: "off",
placeholder: "",
readonly: false
};
let model = { event: 1462799081231 };
let input;
Expand All @@ -46,15 +49,13 @@ describe("fieldDateTime.vue", function() {
});
});

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];

// Rollback
field.disabled = false;
vm.$nextTick( () => {
done();
attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});
Expand Down
32 changes: 14 additions & 18 deletions test/unit/specs/fields/fieldEmail.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";

import Vue from "vue";
import FieldEmail from "src/fields/fieldEmail.vue";
Expand All @@ -20,8 +20,9 @@ describe("fieldEmail.vue", function() {
type: "text",
label: "E-mail",
model: "email",
readonly: false,
placeholder: "Field placeholder"
autocomplete: "off",
placeholder: "Field placeholder",
readonly: false
};
let model = { email: "[email protected]" };
let input;
Expand All @@ -38,9 +39,9 @@ describe("fieldEmail.vue", function() {
expect(input).to.be.defined;
expect(input.type).to.be.equal("email");
expect(input.classList.contains("form-control")).to.be.true;
expect(input.placeholder).to.be.equal(schema.placeholder);
expect(input.readOnly).to.be.false;
expect(input.disabled).to.be.false;
// expect(input.placeholder).to.be.equal(schema.placeholder);
// expect(input.readOnly).to.be.false;
// expect(input.disabled).to.be.false;
});

it("should contain the value", (done) => {
Expand All @@ -50,19 +51,14 @@ describe("fieldEmail.vue", function() {
});
});

it("should set readOnly", (done) => {
schema.readonly = true;
vm.$nextTick( () => {
expect(input.readOnly).to.be.true;
done();
});
});
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
done();
attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});

Expand Down
34 changes: 14 additions & 20 deletions test/unit/specs/fields/fieldGoogleAddress.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";

import Vue from "vue";
import FieldGoogleAddress from "src/fields/fieldGoogleAddress.vue";
Expand All @@ -19,8 +19,9 @@ describe("fieldGoogleAddress.vue", function() {
type: "text",
label: "Address",
model: "address",
readonly: false,
placeholder: "Field placeholder"
autocomplete: "off",
placeholder: "Field placeholder",
readonly: false
};
let model = { address: "Paris, France" };
let input;
Expand All @@ -37,9 +38,9 @@ describe("fieldGoogleAddress.vue", function() {
expect(input).to.be.defined;
expect(input.type).to.be.equal("text");
expect(input.classList.contains("form-control")).to.be.true;
expect(input.placeholder).to.be.equal(schema.placeholder);
expect(input.readOnly).to.be.false;
expect(input.disabled).to.be.false;
// expect(input.placeholder).to.be.equal(schema.placeholder);
// expect(input.readOnly).to.be.false;
// expect(input.disabled).to.be.false;
});

it("should contain the value", (done) => {
Expand All @@ -49,21 +50,14 @@ describe("fieldGoogleAddress.vue", function() {
});
});

it("should set readOnly", (done) => {
schema.readonly = true;
vm.$nextTick( () => {
expect(input.readOnly).to.be.true;
schema.readonly = false;
done();
});
});
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
field.disabled = false;
done();
attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});

Expand Down
26 changes: 11 additions & 15 deletions test/unit/specs/fields/fieldImage.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global sinon */

import { expect } from "chai";
import { createVueField, trigger } from "../util";
import { createVueField, trigger, checkAttribute } from "../util";

import Vue from "vue";
import FieldImage from "src/fields/fieldImage.vue";
Expand All @@ -21,8 +21,9 @@ describe("fieldImage.vue", function() {
type: "image",
label: "Avatar",
model: "avatar",
readonly: false,
placeholder: "Field placeholder"
autocomplete: "off",
placeholder: "Field placeholder",
readonly: false
};
let model = { avatar: "https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg" };
let input;
Expand Down Expand Up @@ -66,19 +67,14 @@ describe("fieldImage.vue", function() {
});
});

it("should set readOnly", (done) => {
schema.readonly = true;
vm.$nextTick( () => {
expect(input.readOnly).to.be.true;
done();
});
});
describe("check optional attribute", () => {
// name which attributes you want to test and that's it.
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];

it("should set disabled", (done) => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
done();
attributes.forEach(function(name) {
it("should set " + name, function(done) {
checkAttribute(name, vm, input, field, schema, done);
});
});
});

Expand Down
Loading

0 comments on commit ebf3f01

Please sign in to comment.