Browse Source

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

* commit 'fb1d053bb9e13ea7a8d0697c172348a51c605649':
  update: 移动位置
  BI-52072 test: 数值区间和可标红的多选下拉单测
es6
windy 5 years ago
parent
commit
d76c0f9ed7
  1. 88
      src/widget/numberinterval/__test__/numberinterval.test.js
  2. 154
      src/widget/searchmultitextvaluecombo/__test__/multitextvalue.combo.search.test.js
  3. 0
      src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js
  4. 0
      src/widget/textvaluedownlistcombo/trigger.textvaluedownlist.js

88
src/widget/numberinterval/__test__/numberinterval.test.js

@ -0,0 +1,88 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/27
*/
describe("NumberInterval", function () {
/**
* test_author_windy
*/
it("setValue", function () {
var widget = BI.Test.createWidget({
type: "bi.number_interval",
});
widget.setValue({
max: 10,
min: 2,
closeMin: true,
closeMax: true
});
expect(widget.getValue()).to.deep.equal({
max: "10",
min: "2",
closeMin: true,
closeMax: true
});
widget.destroy();
});
/**
* test_author_windy
*/
it("defaultValue", function () {
var widget = BI.Test.createWidget({
type: "bi.number_interval",
max: 10,
min: 2,
closeMin: true,
closeMax: true
});
expect(widget.getValue()).to.deep.equal({
max: "10",
min: "2",
closeMin: true,
closeMax: true
});
widget.destroy();
});
/**
* test_author_windy
*/
it("输入报错单editor输入不合法报错", function (done) {
var widget = BI.Test.createWidget({
type: "bi.number_interval",
width: 200,
height: 24
});
widget.element.find(".number-interval-small-editor .bi-input").click();
BI.Test.triggerKeyDown(widget.element.find(".number-interval-small-editor .bi-input"), "A", 65, function () {
expect(widget.element.children(".bi-tip").length).to.not.equal(0);
widget.destroy();
done();
});
});
/**
* test_author_windy
*/
it("输入报错区间不合法报错", function (done) {
var widget = BI.Test.createWidget({
type: "bi.number_interval",
width: 200,
height: 24
});
widget.element.find(".number-interval-small-editor .bi-input").click();
BI.Test.triggerKeyDown(widget.element.find(".number-interval-small-editor .bi-input"), "2", 50, function () {
widget.element.find(".number-interval-big-editor .bi-input").click();
BI.Test.triggerKeyDown(widget.element.find(".number-interval-big-editor .bi-input"), "1", 49, function () {
expect(widget.element.children(".bi-tip").length).to.not.equal(0);
widget.destroy();
done();
});
});
});
});

154
src/widget/searchmultitextvaluecombo/__test__/multitextvalue.combo.search.test.js

@ -0,0 +1,154 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/27
*/
describe("multitextvaluecombo", function () {
var items = BI.map(BI.makeArray(1000, null), function(idx, v) {
return {
text: idx,
value: idx,
title: idx
};
});
var itemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) {
return ".bi-multi-select-popup-view .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")";
});
};
var searchItemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) {
return ".bi-multi-select-search-pane .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")";
});
};
/**
* test_author_windy
**/
it("setValue", function () {
var widget = BI.Test.createWidget({
type: "bi.search_multi_text_value_combo",
width: 220,
items: items
});
widget.setValue({
type: 1,
value: [1, 2]
});
expect(widget.getValue()).to.deep.equal({
type: 1,
value: [1, 2]
});
widget.destroy();
});
/**
* test_author_windy
**/
it("getValue", function () {
var widget = BI.Test.createWidget({
type: "bi.search_multi_text_value_combo",
width: 220,
items: items,
value: {
type: 2,
value: [1, 2, 3]
}
});
expect(widget.getValue()).to.deep.equal({
type: 2,
value: [1, 2, 3]
});
widget.destroy();
});
/**
* test_author_windy
**/
it("点选选值", function (done) {
var widget = BI.Test.createWidget({
type: "bi.search_multi_text_value_combo",
width: 220,
items: items
});
widget.element.find(".bi-multi-select-trigger").click();
// 为什么要delay 300呢,因为按钮有debounce
BI.delay(function () {
// 点选1、2、3
BI.each(itemSelectorGetter([1,2,3]), function (idx, selector) {
widget.element.find(selector).click();
});
// 点全选
widget.element.find(".bi-multi-select-popup-view .bi-label:contains(全选)").click();
// 取消勾选1、2、3
BI.delay(function () {
BI.each(itemSelectorGetter([1,2,3]), function (idx, selector) {
widget.element.find(selector).click();
});
var value = widget.getValue();
expect(value.type).to.equal(2);
expect(value.value).to.deep.equal([0, 1, 2]);
widget.destroy();
done();
}, 300);
}, 300);
});
/**
* test_author_windy
**/
it("搜索选值", function (done) {
var widget = BI.Test.createWidget({
type: "bi.search_multi_text_value_combo",
width: 220,
items: items
});
BI.nextTick(function () {
widget.element.find(".bi-multi-select-trigger .tip-text-style").click();
// 这边为啥要加呢,因为input的setValue中有nextTick
BI.nextTick(function () {
BI.Test.triggerKeyDown(widget.element.find(".bi-multi-select-trigger .bi-input"), "2", 50, function () {
BI.nextTick(function () {
BI.each(searchItemSelectorGetter([1,2]), function (idx, selector) {
widget.element.find(selector).click();
});
expect(widget.getValue()).to.deep.equal({
type: 1,
value: [2, 12]
});
widget.destroy();
done();
});
});
});
});
});
/**
* test_author_windy
**/
it("查看已选", function (done) {
var widget = BI.Test.createWidget({
type: "bi.search_multi_text_value_combo",
width: 220,
items: items,
value: {
type: 1,
value: [1, 2]
}
});
BI.nextTick(function () {
widget.element.find(".bi-multi-select-check-selected-button").click();
BI.delay(function () {
expect(widget.element.find(".display-list-item").length).to.equal(2);
widget.destroy();
done();
}, 300);
});
});
});

0
src/case/combo/textvaluedownlistcombo/combo.textvaluedownlist.js → src/widget/textvaluedownlistcombo/combo.textvaluedownlist.js

0
src/case/combo/textvaluedownlistcombo/trigger.textvaluedownlist.js → src/widget/textvaluedownlistcombo/trigger.textvaluedownlist.js

Loading…
Cancel
Save