Browse Source

BI-51100 test: 单测

es6
windy 5 years ago
parent
commit
22462e828a
  1. 32
      src/widget/editor/__test__/editor.search.test.js
  2. 167
      src/widget/editor/__test__/editor.text.test.js
  3. 36
      src/widget/intervalslider/__test__/intervalslider.test.js
  4. 31
      src/widget/month/__test__/month.test.js

32
src/widget/editor/__test__/editor.search.test.js

@ -95,6 +95,22 @@ describe("searchEditor", function () {
editor.destroy();
});
/**
* test_author_windy
*/
it("getKeywords", function (done) {
var editor = BI.Test.createWidget({
type: "bi.search_editor",
width: 300
});
editor.focus();
BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8 8", 56, function () {
expect(editor.getKeywords()).to.deep.equal(["8", "8"]);
editor.destroy();
done();
})
});
/**
* test_author_windy
@ -179,4 +195,20 @@ describe("searchEditor", function () {
editor.destroy();
});
/**
* test_author_windy
*/
it("getKeywords1", function (done) {
var editor = BI.Test.createWidget({
type: "bi.search_editor",
width: 300
});
editor.focus();
BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8 8", 56, function () {
expect(editor.getKeywords()).to.deep.equal(["8", "8"]);
editor.destroy();
done();
})
});
});

167
src/widget/editor/__test__/editor.text.test.js

@ -2,4 +2,169 @@
* @author windy
* @version 2.0
* Created by windy on 2019/9/9
*/
*/
describe("textEditor", function () {
/**
* test_author_windy
*/
it("defaultValue", function (done) {
var editor = BI.Test.createWidget({
type: "bi.text_editor",
width: 300,
value: "12345",
watermark: "添加合法性判断",
errorText: "长度必须大于4",
validationChecker: function () {
return this.getValue().length > 4;
}
});
expect(editor.element.find(".bi-water-mark").text()).to.equal("添加合法性判断");
expect(editor.element.find(".bi-input").val()).to.equal("12345");
editor.focus();
BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () {
expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("长度必须大于4");
editor.destroy();
done();
})
});
/**
* test_author_windy
*/
it("setValue", function () {
var editor = BI.Test.createWidget({
type: "bi.text_editor",
width: 300,
watermark: "添加合法性判断",
errorText: "长度必须大于4",
validationChecker: function () {
return this.getValue().length > 4;
}
});
editor.setValue("12345");
expect(editor.element.find(".bi-input").val()).to.equal("12345");
editor.destroy();
});
/**
* test_author_windy
*/
it("setErrorText", function (done) {
var editor = BI.Test.createWidget({
type: "bi.text_editor",
width: 300,
watermark: "添加合法性判断",
errorText: "长度必须大于4",
validationChecker: function () {
return this.getValue().length > 4;
}
});
editor.setErrorText("xin_error");
editor.focus();
BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () {
expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("xin_error");
editor.destroy();
done();
});
});
/**
* test_author_windy
*/
it("setWatermark", function () {
var editor = BI.Test.createWidget({
type: "bi.text_editor",
width: 300,
watermark: "添加合法性判断",
errorText: "长度必须大于4",
validationChecker: function () {
return this.getValue().length > 4;
}
});
editor.setWaterMark("xin_water");
expect(editor.element.find(".bi-water-mark").text()).to.equal("xin_water");
editor.destroy();
});
/**
* test_author_windy
*/
it("getValue", function () {
var editor = BI.Test.createWidget({
type: "bi.text_editor",
width: 300,
value: "12346",
watermark: "添加合法性判断",
errorText: "长度必须大于4",
validationChecker: function () {
return this.getValue().length > 4;
}
});
expect(editor.getValue()).to.equal("12346");
editor.destroy();
});
/**
* test_author_windy
*/
it("defaultValue1", function (done) {
var editor = BI.Test.createWidget({
type: "bi.small_text_editor",
width: 300,
value: "12345",
watermark: "添加合法性判断",
errorText: "长度必须大于4",
validationChecker: function () {
return this.getValue().length > 4;
}
});
expect(editor.element.find(".bi-water-mark").text()).to.equal("添加合法性判断");
expect(editor.element.find(".bi-input").val()).to.equal("12345");
editor.focus();
BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () {
expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("长度必须大于4");
editor.destroy();
done();
})
});
/**
* test_author_windy
*/
it("setValue1", function () {
var editor = BI.Test.createWidget({
type: "bi.small_text_editor",
width: 300,
watermark: "添加合法性判断",
errorText: "长度必须大于4",
validationChecker: function () {
return this.getValue().length > 4;
}
});
editor.setValue("12345");
expect(editor.element.find(".bi-input").val()).to.equal("12345");
editor.destroy();
});
/**
* test_author_windy
*/
it("getValue1", function () {
var editor = BI.Test.createWidget({
type: "bi.small_text_editor",
width: 300,
value: "12346",
watermark: "添加合法性判断",
errorText: "长度必须大于4",
validationChecker: function () {
return this.getValue().length > 4;
}
});
expect(editor.getValue()).to.equal("12346");
editor.destroy();
});
});

36
src/widget/intervalslider/__test__/intervalslider.test.js

@ -0,0 +1,36 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/12
*/
describe("intervalSlider", function () {
/**
* test_author_windy
*/
it("defaultValue", function (done) {
var intervalSliderLabel = BI.Test.createWidget({
type: "bi.interval_slider",
width: 300,
unit: "px",
cls: "layout-bg-white",
digit: 1
});
intervalSliderLabel.setMinAndMax({
min: 0,
max: 120
});
intervalSliderLabel.setValue({
min: 10,
max: 120
});
intervalSliderLabel.populate();
BI.nextTick(function () {
expect(intervalSliderLabel.element.find(".sign-editor-text").get(0).innerHTML).to.equal("10.0px");
expect(intervalSliderLabel.element.find(".sign-editor-text").get(1).innerHTML).to.equal("120.0px");
intervalSliderLabel.destroy();
done();
});
});
});

31
src/widget/month/__test__/month.test.js

@ -0,0 +1,31 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/12
*/
describe("month", function () {
/**
* test_author_windy
*/
it("setValue", function () {
var combo = BI.Test.createWidget({
type: "bi.month_combo",
});
combo.setValue(11);
expect(combo.getValue()).to.equal(11);
});
/**
* test_author_windy
*/
it("getValue", function () {
var combo = BI.Test.createWidget({
type: "bi.month_combo",
value: 1
});
expect(combo.getValue()).to.equal(1);
});
});
Loading…
Cancel
Save