-
Notifications
You must be signed in to change notification settings - Fork 533
/
Copy pathfieldLabel.spec.js
62 lines (47 loc) · 1.45 KB
/
fieldLabel.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { expect } from "chai";
import { createVueField } from "../util";
import Vue from "vue";
import FieldLabel from "src/fields/core/fieldLabel.vue";
Vue.component("FieldLabel", FieldLabel);
let el, vm, field;
function createField(test, schema = {}, model = null, disabled = false, options) {
[ el, vm, field ] = createVueField(test, "fieldLabel", schema, model, disabled, options);
}
describe("fieldLabel.vue", function() {
describe("check template", () => {
let schema = {
type: "label",
label: "Timestamp",
model: "timestamp",
fieldClasses: ["applied-class", "another-class"]
};
let model = { timestamp: "2 days ago" };
let span;
before( () => {
createField(this, 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();
});
});
it("should have 2 classes", () => {
expect(span.className.indexOf("applied-class")).not.to.be.equal(-1);
expect(span.className.indexOf("another-class")).not.to.be.equal(-1);
});
});
});