Skip to content

Commit

Permalink
test: add attr checker to switch field
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Sep 26, 2016
1 parent f92b193 commit 2ed434e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/fields/fieldSwitch.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="jade">
label
input(type="checkbox", v-model="value", :disabled="disabled", :name="schema.inputName")
input(type="checkbox", v-model="value", :autocomplete="schema.autocomplete", :disabled="disabled", :name="schema.inputName")
span.label(:data-on="schema.textOn || 'On'", :data-off="schema.textOff || 'Off'")
span.handle
</template>
Expand Down
12 changes: 11 additions & 1 deletion test/unit/specs/fields/fieldSwitch.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 FieldSwitch from "src/fields/fieldSwitch.vue";
Expand Down Expand Up @@ -44,6 +44,16 @@ describe("FieldSwitch.vue", function() {
});
});

describe("check optional attribute", () => {
let attributes = ["autocomplete", "disabled", "inputName"];

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

it("should contain the default On/Off texts", () => {
let span = field.$el.querySelector("span.label");
expect(span.getAttribute("data-on")).to.be.equal("On");
Expand Down

0 comments on commit 2ed434e

Please sign in to comment.