-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
315 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { expect } from "chai"; | ||
import { createVueField, trigger } from "../util"; | ||
|
||
import Vue from "vue"; | ||
import FieldColor from "src/fields/fieldColor.vue"; | ||
|
||
Vue.component("FieldColor", FieldColor); | ||
|
||
let el, vm, field; | ||
|
||
function createField(schema = {}, model = null, disabled = false, options) { | ||
[ el, vm, field ] = createVueField("fieldColor", schema, model, disabled, options); | ||
} | ||
|
||
describe("fieldColor.vue", () => { | ||
|
||
describe("check template", () => { | ||
let schema = { | ||
type: "color", | ||
label: "Color", | ||
model: "color" | ||
}; | ||
let model = { color: "#ff8822" }; | ||
let input; | ||
|
||
before( () => { | ||
createField(schema, model, false); | ||
input = el.getElementsByTagName("input")[0]; | ||
}); | ||
|
||
it("should contain an input color element", () => { | ||
expect(field).to.be.exist; | ||
expect(field.$el).to.be.exist; | ||
|
||
expect(input).to.be.defined; | ||
expect(input.type).to.be.equal("color"); | ||
//expect(input.classList.contains("form-control")).to.be.true; | ||
expect(input.disabled).to.be.false; | ||
}); | ||
|
||
it("should contain the value", (done) => { | ||
vm.$nextTick( () => { | ||
expect(input.value).to.be.equal("#ff8822"); | ||
done(); | ||
}); | ||
}); | ||
|
||
it("should set disabled", (done) => { | ||
field.disabled = true; | ||
vm.$nextTick( () => { | ||
expect(input.disabled).to.be.true; | ||
done(); | ||
}); | ||
}); | ||
|
||
it("input value should be the model value after changed", (done) => { | ||
model.color = "#ffff00"; | ||
vm.$nextTick( () => { | ||
expect(input.value).to.be.equal("#ffff00"); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
it("model value should be the input value if changed", (done) => { | ||
input.value = "#123456"; | ||
trigger(input, "change"); | ||
|
||
vm.$nextTick( () => { | ||
expect(model.color).to.be.equal("#123456"); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { expect } from "chai"; | ||
import { createVueField, trigger } from "../util"; | ||
|
||
import Vue from "vue"; | ||
import FieldLabel from "src/fields/fieldLabel.vue"; | ||
|
||
Vue.component("FieldLabel", FieldLabel); | ||
|
||
let el, vm, field; | ||
|
||
function createField(schema = {}, model = null, disabled = false, options) { | ||
[ el, vm, field ] = createVueField("fieldLabel", schema, model, disabled, options); | ||
} | ||
|
||
describe("fieldLabel.vue", () => { | ||
|
||
describe("check template", () => { | ||
let schema = { | ||
type: "label", | ||
label: "Timestamp", | ||
model: "timestamp" | ||
}; | ||
let model = { timestamp: "2 days ago" }; | ||
let span; | ||
|
||
before( () => { | ||
createField(schema, model, false); | ||
span = el.getElementsByTagName("span")[0]; | ||
}); | ||
|
||
it("should contain a span element", () => { | ||
expect(field).to.be.exist; | ||
expect(field.$el).to.be.exist; | ||
|
||
expect(span).to.be.defined; | ||
}); | ||
|
||
it("should contain the value", (done) => { | ||
vm.$nextTick( () => { | ||
expect(span.textContent).to.be.equal("2 days ago"); | ||
done(); | ||
}); | ||
}); | ||
|
||
it("input value should be the model value after changed", (done) => { | ||
model.timestamp = "Foo bar"; | ||
vm.$nextTick( () => { | ||
expect(span.textContent).to.be.equal("Foo bar"); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.