Browse Source

Merge pull request #1254 in VISUAL/fineui from ~WINDY/fineui:master to master

* commit '1af26544b9ebf77b79bd193deb12586f65f8cd8e':
  BI-52072 test: 单测补充
es6
windy 5 years ago
parent
commit
904102c104
  1. 2
      src/widget/datetime/__test__/datetime.test.js
  2. 1
      src/widget/downlist/__test__/downlist.test.js
  3. 89
      src/widget/selecttree/__test__/selecttree.combo.test.js
  4. 110
      src/widget/singletree/__test__/singletree.combo.test.js
  5. 136
      src/widget/textvaluedownlistcombo/__test__/combo.textvaluedownlist.test.js
  6. 171
      src/widget/time/__test__/time.combo.test.js

2
src/widget/datetime/__test__/datetime.test.js

@ -61,7 +61,7 @@ describe("DateTime", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("点击取消不选值", function () { it("点击取消不选值", function (done) {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.date_time_combo", type: "bi.date_time_combo",
value: { value: {

1
src/widget/downlist/__test__/downlist.test.js

@ -35,6 +35,7 @@ describe("DownListCombo", function () {
BI.nextTick(function () { BI.nextTick(function () {
downListCombo.element.find(".bi-down-list-group:last-child .bi-down-list-item").click(); downListCombo.element.find(".bi-down-list-group:last-child .bi-down-list-item").click();
expect(downListCombo.getValue()).to.deep.equal([ { value: 33 } ]); expect(downListCombo.getValue()).to.deep.equal([ { value: 33 } ]);
downListCombo.destroy();
done(); done();
}); });
}); });

89
src/widget/selecttree/__test__/selecttree.combo.test.js

@ -0,0 +1,89 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/2/17
*/
describe("select_tree", function () {
var items = [{
id: 1,
text: "第一项",
value: "1"
}, {
id: 2,
text: "第二项",
value: "2"
}, {
id: 3,
text: "第三项",
value: "3",
open: true
}, {
id: 11,
pId: 1,
text: "子项1",
value: "11"
}, {
id: 12,
pId: 1,
text: "子项2",
value: "12"
}, {
id: 13,
pId: 1,
text: "子项3",
value: "13"
}, {
id: 31,
pId: 3,
text: "子项1",
value: "31"
}, {
id: 32,
pId: 3,
text: "子项2",
value: "32"
}, {
id: 33,
pId: 3,
text: "子项3",
value: "33"
}];
/**
* test_author_windy
**/
it("defaultValue", function () {
var tree = BI.Test.createWidget({
type: "bi.select_tree_combo",
width: 300,
height: 24,
items: BI.deepClone(items),
value: "1"
});
expect(tree.getValue()[0]).to.equal("1");
tree.destroy();
});
/**
* test_author_windy
**/
it("点选选值", function (done) {
var tree = BI.Test.createWidget({
type: "bi.select_tree_combo",
width: 300,
height: 24,
allowEdit: true,
items: BI.deepClone(items),
value: "2"
});
tree.element.find(".bi-single-tree-trigger").click();
BI.nextTick(function () {
tree.element.find(".bi-select-tree-first-plus-group-node").click();
expect(tree.getValue()[0]).to.equal("1");
tree.destroy();
done();
});
});
});

110
src/widget/singletree/__test__/singletree.combo.test.js

@ -0,0 +1,110 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/2/17
*/
describe("single_tree", function () {
var items = [{
id: 1,
text: "第一项",
value: "1"
}, {
id: 2,
text: "第二项",
value: "2"
}, {
id: 3,
text: "第三项",
value: "3",
open: true
}, {
id: 11,
pId: 1,
text: "子项1",
value: "11"
}, {
id: 12,
pId: 1,
text: "子项2",
value: "12"
}, {
id: 13,
pId: 1,
text: "子项3",
value: "13"
}, {
id: 31,
pId: 3,
text: "子项1",
value: "31"
}, {
id: 32,
pId: 3,
text: "子项2",
value: "32"
}, {
id: 33,
pId: 3,
text: "子项3",
value: "33"
}];
/**
* test_author_windy
**/
it("defaultValue", function () {
var tree = BI.Test.createWidget({
type: "bi.single_tree_combo",
width: 300,
height: 24,
items: BI.deepClone(items),
value: "2"
});
expect(tree.getValue()[0]).to.equal("2");
tree.destroy();
});
/**
* test_author_windy
**/
it("点选选值_选择父节点", function (done) {
var tree = BI.Test.createWidget({
type: "bi.single_tree_combo",
width: 300,
height: 24,
allowEdit: true,
items: BI.deepClone(items),
value: "2"
});
tree.element.find(".bi-single-tree-trigger").click();
BI.nextTick(function () {
tree.element.find(".bi-single-tree-first-plus-group-node").click();
expect(tree.getValue()[0]).to.equal("2");
tree.destroy();
done();
});
});
/**
* test_author_windy
**/
it("点选选值_选择叶子节点", function (done) {
var tree = BI.Test.createWidget({
type: "bi.single_tree_combo",
width: 300,
height: 24,
allowEdit: true,
items: BI.deepClone(items),
value: "33"
});
tree.element.find(".bi-single-tree-trigger").click();
BI.nextTick(function () {
tree.element.find(".bi-mid-tree-leaf-item").click();
expect(tree.getValue()[0]).to.equal("32");
tree.destroy();
done();
});
});
});

136
src/widget/textvaluedownlistcombo/__test__/combo.textvaluedownlist.test.js

@ -0,0 +1,136 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/2/17
*/
describe("TextValueDownListCombo", function () {
/**
* test_author_windy
*/
it("defaultValue", function () {
var downListCombo = BI.Test.createWidget({
type: "bi.text_value_down_list_combo",
adjustLength: 10,
items: [[{
text: "属于",
value: 1,
cls: "dot-e-font"
}, {
text: "不属于",
value: 2,
cls: "dot-e-font"
}], [{
el: {
text: "大于",
value: 3,
iconCls1: "dot-e-font"
},
value: 3,
children: [{
text: "固定值",
value: 4,
cls: "dot-e-font"
}, {
text: "平均值",
value: 5,
cls: "dot-e-font"
}]
}]]
});
downListCombo.setValue(2);
expect(downListCombo.getValue()[0]).to.deep.equal(2);
downListCombo.destroy();
});
/**
* test_author_windy
*/
it("点击父亲选值", function (done) {
var downListCombo = BI.Test.createWidget({
type: "bi.text_value_down_list_combo",
height: 30,
width: 300,
items: [[{
text: "属于",
value: 1,
cls: "dot-e-font"
}, {
text: "不属于",
value: 2,
cls: "dot-e-font"
}], [{
el: {
text: "大于",
value: 3,
iconCls1: "dot-e-font"
},
value: 3,
children: [{
text: "固定值",
value: 4,
cls: "dot-e-font"
}, {
text: "平均值",
value: 5,
cls: "dot-e-font"
}]
}]]
});
downListCombo.element.find(".pull-down-font").click();
BI.nextTick(function () {
downListCombo.element.find(".bi-down-list-group:first-child .bi-down-list-item").click();
expect(downListCombo.getValue()[0]).to.deep.equal(2);
downListCombo.destroy();
done();
});
});
/**
* test_author_windy
*/
it("点击儿子选值", function (done) {
var downListCombo = BI.Test.createWidget({
type: "bi.text_value_down_list_combo",
height: 30,
width: 30,
items: [[{
text: "属于",
value: 1,
cls: "dot-e-font"
}, {
text: "不属于",
value: 2,
cls: "dot-e-font"
}], [{
el: {
text: "大于",
value: 3,
iconCls1: "dot-e-font"
},
value: 3,
children: [{
text: "固定值",
value: 4,
cls: "dot-e-font"
}, {
text: "平均值",
value: 5,
cls: "dot-e-font"
}]
}]]
});
downListCombo.element.find(".pull-down-font").click();
BI.Test.triggerMouseover(downListCombo.element.find(".bi-down-list-group:last-child .bi-down-list-group-item"), function () {
BI.nextTick(function () {
downListCombo.element.find(".child-down-list-item:first-child").click();
expect(downListCombo.getValue()[0]).to.deep.equal(4);
downListCombo.destroy();
done();
});
});
});
});

171
src/widget/time/__test__/time.combo.test.js

@ -0,0 +1,171 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/2/17
*/
describe("TimeCombo", function () {
/**
* test_author_windy
*/
it("defaultValue", function (done) {
var timeCombo = BI.Test.createWidget({
type: "bi.time_combo",
value: {
hour: 12,
minute: 0,
second: 0
},
width: 300
});
BI.nextTick(function () {
expect(timeCombo.element.find(".bi-time-trigger .bi-label").text()).to.equal("12:00:00");
timeCombo.destroy();
done();
});
});
/**
* test_author_windy
*/
it("测试输入值收起下拉清空值下拉出现", function (done) {
var timeCombo = BI.Test.createWidget({
type: "bi.time_combo",
allowEdit: true,
value: {
hour: 12,
minute: 0,
second: 0
},
width: 300
});
BI.nextTick(function () {
timeCombo.element.find(".bi-time-trigger .bi-basic-button").click();
// 输入8, 检查popup是否收起
BI.Test.triggerKeyDown(timeCombo.element.find(".bi-time-trigger .bi-input"), "1", 49, function () {
BI.nextTick(function () {
expect(timeCombo.element.find(".bi-time-trigger + .bi-popup-view").css("display")).to.equal("none");
// 清空输入, 检查popup是否弹出
BI.Test.triggerKeyDown(timeCombo.element.find(".bi-time-trigger .bi-input"), "", BI.KeyCode.BACKSPACE, function () {
BI.nextTick(function () {
expect(timeCombo.element.find(".bi-time-trigger + .bi-popup-view").css("display")).to.equal("block");
timeCombo.destroy();
done();
});
});
});
});
});
});
/**
* test_author_windy
*/
it("下拉后直接点击外部的触发的confirm", function (done) {
var timeCombo = BI.Test.createWidget({
type: "bi.time_combo",
width: 220,
height: 30,
});
// 点击日期,是否收起下拉
BI.nextTick(function () {
timeCombo.element.find(".bi-time-trigger .bi-basic-button").click();
BI.nextTick(function () {
var input = timeCombo.element.find(".bi-time-trigger .bi-input");
BI.Test.triggerKeyDown(input, null, BI.KeyCode.ENTER, function () {
BI.delay(function () {
expect(timeCombo.element.find(".bi-time-trigger + .bi-popup-view").css("display")).to.equal("none");
timeCombo.destroy();
done();
}, 300);
});
})
});
});
/**
* test_author_windy
*/
it("点击清空", function (done) {
var timeCombo = BI.Test.createWidget({
type: "bi.time_combo",
width: 220,
height: 30,
value: {
hour: 12,
minute: 0,
second: 0
},
});
timeCombo.element.find(".bi-time-trigger .bi-basic-button").click();
BI.nextTick(function () {
timeCombo.element.find(".bi-date-time-popup .bi-text:contains(清空)").parent().click();
expect(BI.isNull(timeCombo.getValue())).to.equal(true);
timeCombo.destroy();
done();
})
});
/**
* test_author_windy
*/
it("点击确定", function (done) {
var timeCombo = BI.Test.createWidget({
type: "bi.time_combo",
width: 220,
height: 30,
value: {
hour: 12,
minute: 0,
second: 0
},
});
timeCombo.element.find(".bi-time-trigger .bi-basic-button").click();
BI.nextTick(function () {
timeCombo.element.find(".bi-date-time-popup .bi-text:contains(确定)").parent().click();
expect(timeCombo.getValue()).to.deep.equal({
hour: 12,
minute: 0,
second: 0
});
timeCombo.destroy();
done();
})
});
/**
* test_author_windy
*/
it("trigger的输入日期后confirm", function (done) {
var timeCombo = BI.Test.createWidget({
type: "bi.time_combo",
width: 220,
height: 30,
value: {
hour: 12,
minute: 0,
second: 0
},
});
BI.nextTick(function () {
timeCombo.element.find(".bi-time-trigger .bi-basic-button").click();
BI.nextTick(function () {
var input = timeCombo.element.find(".bi-time-trigger .bi-input");
input.val("11:11:11");
BI.Test.triggerKeyDown(timeCombo.element.find(".bi-time-trigger .bi-input"), null, BI.KeyCode.ENTER, function () {
BI.delay(function () {
expect(timeCombo.element.find(".bi-time-trigger .bi-text-button").text()).to.equal("11:11:11");
timeCombo.destroy();
done();
}, 300);
});
});
})
});
});
Loading…
Cancel
Save