Skip to content

Commit 2ed434e

Browse files
committed
test: add attr checker to switch field
1 parent f92b193 commit 2ed434e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/fields/fieldSwitch.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template lang="jade">
22
label
3-
input(type="checkbox", v-model="value", :disabled="disabled", :name="schema.inputName")
3+
input(type="checkbox", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :name="schema.inputName")
44
span.label(:data-on="schema.textOn || 'On'", :data-off="schema.textOff || 'Off'")
55
span.handle
66
</template>

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

+11-1
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 FieldSwitch from "src/fields/fieldSwitch.vue";
@@ -44,6 +44,16 @@ describe("FieldSwitch.vue", function() {
4444
});
4545
});
4646

47+
describe("check optional attribute", () => {
48+
let attributes = ["autocomplete", "disabled", "inputName"];
49+
50+
attributes.forEach(function(name) {
51+
it("should set " + name, function(done) {
52+
checkAttribute(name, vm, input, field, schema, done);
53+
});
54+
});
55+
});
56+
4757
it("should contain the default On/Off texts", () => {
4858
let span = field.$el.querySelector("span.label");
4959
expect(span.getAttribute("data-on")).to.be.equal("On");

0 commit comments

Comments
 (0)