Skip to content

Commit

Permalink
test: add file input attr test
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Sep 26, 2016
1 parent 1627c71 commit 352fb20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions dev/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ module.exports = {
required: true,
browse: true,
hideInput: false,
inputName: "photo",
validator: validators.required
},
{
Expand Down
17 changes: 14 additions & 3 deletions test/unit/specs/fields/fieldImage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("fieldImage.vue", function() {
readonly: false
};
let model = { avatar: "https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg" };
let input;
let input, fileInput;

before( () => {
createField(this, schema, model, false);
Expand All @@ -46,7 +46,7 @@ describe("fieldImage.vue", function() {
});

it("should contain a file input element", () => {
let fileInput = el.querySelector("input[type=file]");
fileInput = el.querySelector("input[type=file]");
expect(fileInput).to.be.defined;
expect(fileInput.classList.contains("form-control")).to.be.true;
expect(fileInput.classList.contains("file")).to.be.true;
Expand All @@ -67,7 +67,7 @@ describe("fieldImage.vue", function() {
});
});

describe("check optional attribute", () => {
describe("check optional attribute on text input", () => {
let attributes = ["autocomplete", "disabled", "placeholder", "readonly"];

attributes.forEach(function(name) {
Expand All @@ -77,6 +77,17 @@ describe("fieldImage.vue", function() {
});
});

// TODO: not working inputName test.
describe.skip("check optional attribute on file input", () => {
let attributes = ["disabled", "inputName"];

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

it("input value should be the model value after changed", (done) => {
model.avatar = "https://s3.amazonaws.com/uifaces/faces/twitter/felipebsb/128.jpg";
vm.$nextTick( () => {
Expand Down

0 comments on commit 352fb20

Please sign in to comment.