Skip to content

Commit 46fd658

Browse files
author
Lionel Bijaoui
committed
Improve code coverage score
- Fix fieldUpload
1 parent 6f222ec commit 46fd658

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/fields/core/fieldUpload.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export default {
2525
mixins: [abstractField],
2626
methods: {
2727
onChange($event) {
28-
if (isFunction(this.schema.onChanged)) {
28+
if (isFunction(this.fieldOptions.onChanged)) {
2929
// Schema has defined onChange method.
30-
this.schema.onChanged.call(this, this.model, this.schema, $event, this);
30+
this.fieldOptions.onChanged.call(this, this.model, this.schema, $event, this);
3131
}
3232
}
3333
}

tests/unit/specs/fields/fieldUpload.spec.js

+32
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,36 @@ describe("fieldUpload.vue", () => {
8484
});
8585
});
8686
});
87+
describe("check onChange methods", () => {
88+
let schema = {
89+
type: "upload",
90+
label: "Upload",
91+
inputName: "testupload",
92+
placeholder: "",
93+
readonly: false,
94+
required: false,
95+
disabled: false,
96+
fieldOptions: {
97+
multiple: true,
98+
accept: "image/*"
99+
}
100+
};
101+
let model = {};
102+
let input;
103+
104+
before(() => {
105+
createField({ schema, model });
106+
input = wrapper.find("input");
107+
schema.fieldOptions = { inputType: "file" };
108+
});
109+
110+
it("should contain an input text element", () => {
111+
schema.fieldOptions.onChanged = sinon.spy();
112+
wrapper.setProps({ schema: { ...schema } });
113+
114+
input.trigger("change", { $event: "MyEvent" });
115+
116+
expect(schema.fieldOptions.onChanged.calledOnce).to.be.true;
117+
});
118+
});
87119
});

0 commit comments

Comments
 (0)