Skip to content

Commit e637c60

Browse files
committed
Hint test
New test for a function hint.
1 parent 4fe380e commit e637c60

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

dev/full/schema.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ module.exports = {
319319
type: "textArea",
320320
label: "Biography (textArea field)",
321321
model: "bio",
322-
hint: function (model) {
322+
hint(model) {
323323
if (model && model.bio) {
324324
return model.bio.length + " of max 500 characters used!";
325325
}

test/unit/specs/VueFormGenerator.spec.js

+40
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,46 @@ describe("VueFormGenerator.vue", () => {
440440

441441
});
442442

443+
describe("check fieldHint with function", () => {
444+
let schema = {
445+
fields: [
446+
{
447+
type: "textArea",
448+
label: "Note",
449+
model: "note",
450+
max: 500,
451+
rows: 4,
452+
hint(model) {
453+
if (model && model.note) {
454+
return model.note.length + " of max 500 characters used!";
455+
}
456+
}
457+
}
458+
]
459+
};
460+
461+
let model = {
462+
note: "John Doe"
463+
};
464+
465+
before( () => {
466+
createFormGenerator(schema, model);
467+
});
468+
469+
it("should be applay", () => {
470+
expect(el.querySelector(".form-group .hint").textContent).to.be.equal("8 of max 500 characters used!");
471+
});
472+
473+
it("should be changed", (done) => {
474+
model.note= "Dr. John Doe";
475+
vm.$nextTick(() => {
476+
expect(el.querySelector(".form-group .hint").textContent).to.be.equal("12 of max 500 characters used!");
477+
done();
478+
});
479+
});
480+
481+
});
482+
443483
describe("check fieldFeatured with function", () => {
444484
let schema = {
445485
fields: [

0 commit comments

Comments
 (0)