Skip to content

Commit ebf3f01

Browse files
test: update to many test to check optional attributes
1 parent 2e5e16b commit ebf3f01

20 files changed

+250
-246
lines changed

test/unit/specs/fields/fieldCheckbox.spec.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import { createVueField, trigger } from "../util";
2+
import { createVueField, trigger, checkAttribute } from "../util";
33

44
import Vue from "vue";
55
import FieldCheckbox from "src/fields/fieldCheckbox.vue";
@@ -18,7 +18,8 @@ describe("FieldCheckbox.vue", function() {
1818
let schema = {
1919
type: "checkbox",
2020
label: "Status",
21-
model: "status"
21+
model: "status",
22+
autocomplete: "off"
2223
};
2324
let model = { status: true };
2425
let input;
@@ -34,7 +35,7 @@ describe("FieldCheckbox.vue", function() {
3435

3536
expect(input).to.be.defined;
3637
expect(input.type).to.be.equal("checkbox");
37-
expect(input.disabled).to.be.false;
38+
// expect(input.disabled).to.be.false;
3839
});
3940

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

47-
it("should set disabled", (done) => {
48-
field.disabled = true;
49-
vm.$nextTick( () => {
50-
expect(input.disabled).to.be.true;
51-
done();
48+
describe("check optional attribute", () => {
49+
// name which attributes you want to test and that's it.
50+
let attributes = ["autocomplete", "disabled"];
51+
52+
attributes.forEach(function(name) {
53+
it("should set " + name, function(done) {
54+
checkAttribute(name, vm, input, field, schema, done);
55+
});
5256
});
5357
});
5458

test/unit/specs/fields/fieldChecklist.spec.js

-8
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@ describe("fieldChecklist.vue", function() {
6464
expect(isChecked(6)).to.be.true;
6565
});
6666

67-
/*it("should set disabled", (done) => {
68-
field.disabled = true;
69-
vm.$nextTick( () => {
70-
expect(listbox.disabled).to.be.true;
71-
done();
72-
});
73-
});*/
74-
7567
it("listbox value should be the model value after changed", (done) => {
7668
model.skills = ["ReactJS"];
7769
vm.$nextTick( () => {

test/unit/specs/fields/fieldCleave.spec.js

+13-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import { createVueField, trigger } from "../util";
2+
import { createVueField, trigger, checkAttribute } from "../util";
33

44
import Vue from "vue";
55
import FieldCleave from "src/fields/fieldCleave.vue";
@@ -19,8 +19,9 @@ describe("fieldCleave.vue", function() {
1919
type: "masked",
2020
label: "Phone",
2121
model: "phone",
22+
autocomplete: "off",
23+
placeholder: "",
2224
readonly: false,
23-
placeholder: "Field placeholder",
2425
cleaveOptions: {
2526
phone: true,
2627
phoneRegionCode: "HU",
@@ -41,9 +42,9 @@ describe("fieldCleave.vue", function() {
4142
expect(input).to.be.defined;
4243
expect(input.type).to.be.equal("text");
4344
expect(input.classList.contains("form-control")).to.be.true;
44-
expect(input.placeholder).to.be.equal(schema.placeholder);
45-
expect(input.readOnly).to.be.false;
46-
expect(input.disabled).to.be.false;
45+
// expect(input.placeholder).to.be.equal(schema.placeholder);
46+
// expect(input.readOnly).to.be.false;
47+
// expect(input.disabled).to.be.false;
4748
});
4849

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

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

65-
it("should set disabled", (done) => {
66-
field.disabled = true;
67-
vm.$nextTick( () => {
68-
expect(input.disabled).to.be.true;
69-
field.disabled = false;
70-
done();
61+
attributes.forEach(function(name) {
62+
it("should set " + name, function(done) {
63+
checkAttribute(name, vm, input, field, schema, done);
64+
});
7165
});
7266
});
7367

test/unit/specs/fields/fieldColor.spec.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import { createVueField, trigger } from "../util";
2+
import { createVueField, trigger, checkAttribute } from "../util";
33

44
import Vue from "vue";
55
import FieldColor from "src/fields/fieldColor.vue";
@@ -18,7 +18,8 @@ describe("fieldColor.vue", function() {
1818
let schema = {
1919
type: "color",
2020
label: "Color",
21-
model: "color"
21+
model: "color",
22+
autocomplete: "off"
2223
};
2324
let model = { color: "#ff8822" };
2425
let input;
@@ -35,7 +36,7 @@ describe("fieldColor.vue", function() {
3536
expect(input).to.be.defined;
3637
expect(input.type).to.be.equal("color");
3738
//expect(input.classList.contains("form-control")).to.be.true;
38-
expect(input.disabled).to.be.false;
39+
// expect(input.disabled).to.be.false;
3940
});
4041

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

48-
it("should set disabled", (done) => {
49-
field.disabled = true;
50-
vm.$nextTick( () => {
51-
expect(input.disabled).to.be.true;
52-
done();
49+
describe("check optional attribute", () => {
50+
// name which attributes you want to test and that's it.
51+
let attributes = ["autocomplete"];
52+
53+
attributes.forEach(function(name) {
54+
it("should set " + name, function(done) {
55+
checkAttribute(name, vm, input, field, schema, done);
56+
});
5357
});
5458
});
5559

test/unit/specs/fields/fieldDateTime.spec.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import { createVueField, trigger } from "../util";
2+
import { createVueField, trigger, checkAttribute } from "../util";
33
import moment from "moment";
44

55
import Vue from "vue";
@@ -19,7 +19,10 @@ describe("fieldDateTime.vue", function() {
1919
let schema = {
2020
type: "dateTime",
2121
label: "Event",
22-
model: "event"
22+
model: "event",
23+
autocomplete: "off",
24+
placeholder: "",
25+
readonly: false
2326
};
2427
let model = { event: 1462799081231 };
2528
let input;
@@ -46,15 +49,13 @@ describe("fieldDateTime.vue", function() {
4649
});
4750
});
4851

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

54-
// Rollback
55-
field.disabled = false;
56-
vm.$nextTick( () => {
57-
done();
56+
attributes.forEach(function(name) {
57+
it("should set " + name, function(done) {
58+
checkAttribute(name, vm, input, field, schema, done);
5859
});
5960
});
6061
});

test/unit/specs/fields/fieldEmail.spec.js

+14-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import { createVueField, trigger } from "../util";
2+
import { createVueField, trigger, checkAttribute } from "../util";
33

44
import Vue from "vue";
55
import FieldEmail from "src/fields/fieldEmail.vue";
@@ -20,8 +20,9 @@ describe("fieldEmail.vue", function() {
2020
type: "text",
2121
label: "E-mail",
2222
model: "email",
23-
readonly: false,
24-
placeholder: "Field placeholder"
23+
autocomplete: "off",
24+
placeholder: "Field placeholder",
25+
readonly: false
2526
};
2627
let model = { email: "[email protected]" };
2728
let input;
@@ -38,9 +39,9 @@ describe("fieldEmail.vue", function() {
3839
expect(input).to.be.defined;
3940
expect(input.type).to.be.equal("email");
4041
expect(input.classList.contains("form-control")).to.be.true;
41-
expect(input.placeholder).to.be.equal(schema.placeholder);
42-
expect(input.readOnly).to.be.false;
43-
expect(input.disabled).to.be.false;
42+
// expect(input.placeholder).to.be.equal(schema.placeholder);
43+
// expect(input.readOnly).to.be.false;
44+
// expect(input.disabled).to.be.false;
4445
});
4546

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

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

61-
it("should set disabled", (done) => {
62-
field.disabled = true;
63-
vm.$nextTick( () => {
64-
expect(input.disabled).to.be.true;
65-
done();
58+
attributes.forEach(function(name) {
59+
it("should set " + name, function(done) {
60+
checkAttribute(name, vm, input, field, schema, done);
61+
});
6662
});
6763
});
6864

test/unit/specs/fields/fieldGoogleAddress.spec.js

+14-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import { createVueField, trigger } from "../util";
2+
import { createVueField, trigger, checkAttribute } from "../util";
33

44
import Vue from "vue";
55
import FieldGoogleAddress from "src/fields/fieldGoogleAddress.vue";
@@ -19,8 +19,9 @@ describe("fieldGoogleAddress.vue", function() {
1919
type: "text",
2020
label: "Address",
2121
model: "address",
22-
readonly: false,
23-
placeholder: "Field placeholder"
22+
autocomplete: "off",
23+
placeholder: "Field placeholder",
24+
readonly: false
2425
};
2526
let model = { address: "Paris, France" };
2627
let input;
@@ -37,9 +38,9 @@ describe("fieldGoogleAddress.vue", function() {
3738
expect(input).to.be.defined;
3839
expect(input.type).to.be.equal("text");
3940
expect(input.classList.contains("form-control")).to.be.true;
40-
expect(input.placeholder).to.be.equal(schema.placeholder);
41-
expect(input.readOnly).to.be.false;
42-
expect(input.disabled).to.be.false;
41+
// expect(input.placeholder).to.be.equal(schema.placeholder);
42+
// expect(input.readOnly).to.be.false;
43+
// expect(input.disabled).to.be.false;
4344
});
4445

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

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

61-
it("should set disabled", (done) => {
62-
field.disabled = true;
63-
vm.$nextTick( () => {
64-
expect(input.disabled).to.be.true;
65-
field.disabled = false;
66-
done();
57+
attributes.forEach(function(name) {
58+
it("should set " + name, function(done) {
59+
checkAttribute(name, vm, input, field, schema, done);
60+
});
6761
});
6862
});
6963

test/unit/specs/fields/fieldImage.spec.js

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* global sinon */
22

33
import { expect } from "chai";
4-
import { createVueField, trigger } from "../util";
4+
import { createVueField, trigger, checkAttribute } from "../util";
55

66
import Vue from "vue";
77
import FieldImage from "src/fields/fieldImage.vue";
@@ -21,8 +21,9 @@ describe("fieldImage.vue", function() {
2121
type: "image",
2222
label: "Avatar",
2323
model: "avatar",
24-
readonly: false,
25-
placeholder: "Field placeholder"
24+
autocomplete: "off",
25+
placeholder: "Field placeholder",
26+
readonly: false
2627
};
2728
let model = { avatar: "https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg" };
2829
let input;
@@ -66,19 +67,14 @@ describe("fieldImage.vue", function() {
6667
});
6768
});
6869

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

77-
it("should set disabled", (done) => {
78-
field.disabled = true;
79-
vm.$nextTick( () => {
80-
expect(input.disabled).to.be.true;
81-
done();
74+
attributes.forEach(function(name) {
75+
it("should set " + name, function(done) {
76+
checkAttribute(name, vm, input, field, schema, done);
77+
});
8278
});
8379
});
8480

0 commit comments

Comments
 (0)