Browse Source

BI-61182 test: 单测up to 50%

es6
windy 4 years ago
parent
commit
9b3810d19a
  1. 64
      src/case/combo/textvaluecheckcombo/__test__/combo.textvaluecheck.test.js
  2. 304
      src/widget/multiselect/__test__/multiselect.loader.nobar.test.js
  3. 121
      src/widget/singleselect/__test__/singleselect.insert.combo.test.js

64
src/case/combo/textvaluecheckcombo/__test__/combo.textvaluecheck.test.js

@ -0,0 +1,64 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/3/5
*/
describe("text_value_check_combo", function () {
var items = BI.map(BI.makeArray(11, null), function(idx, v) {
return {
text: idx,
value: idx,
title: idx
};
});
/**
* test_author_windy
**/
it("setValue", function () {
var widget = BI.Test.createWidget({
type: "bi.text_value_check_combo",
width: 220,
height: 24,
items: items
});
widget.setValue(2);
expect(widget.getValue()[0]).to.equal(2);
widget.destroy();
});
/**
* test_author_windy
**/
it("getValue", function () {
var widget = BI.Test.createWidget({
type: "bi.text_value_check_combo",
width: 220,
items: items,
value: 2
});
expect(widget.getValue()[0]).to.equal(2);
widget.destroy();
});
/**
* test_author_windy
**/
it("点选选值", function (done) {
var widget = BI.Test.createWidget({
type: "bi.text_value_check_combo",
width: 220,
items: items
});
widget.element.find(".bi-select-text-trigger").click();
// 为什么要delay 300呢,因为按钮有debounce
BI.delay(function () {
widget.element.find(".bi-single-select-item:contains(10)").click();
expect(widget.getValue()[0]).to.equal(10);
widget.destroy();
done();
}, 300);
});
});

304
src/widget/multiselect/__test__/multiselect.loader.nobar.test.js

@ -2,4 +2,306 @@
* @author windy
* @version 2.0
* Created by windy on 2019/9/18
*/
*/
describe("multi_select_no_bar_series", function () {
var _getItemsByTimes = function (items, times) {
var res = [];
for (var i = (times - 1) * 100; items[i] && i < times * 100; i++) {
res.push(items[i]);
}
return res;
};
var _hasNextByTimes = function (items, times) {
return times * 100 < items.length;
};
var _itemsCreator = function (options, callback) {
var items = BI.map(BI.makeArray(100, null), function(idx, v) {
return {
text: idx,
value: idx,
title: idx
};
});
var keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
BI.each(keywords, function (i, kw) {
var search = BI.Func.getSearchResult(items, kw);
items = search.match.concat(search.find);
});
if (options.selectedValues) {// 过滤
var filter = BI.makeObject(options.selectedValues, true);
items = BI.filter(items, function (i, ob) {
return !filter[ob.value];
});
}
if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({
items: items
});
return;
}
if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({count: items.length});
return;
}
callback({
items: _getItemsByTimes(items, options.times),
hasNext: _hasNextByTimes(items, options.times)
});
};
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.multi_select_no_bar_combo",
width: 220,
itemsCreator: _itemsCreator
});
widget.setValue([1, 2]);
expect(widget.getValue()).to.deep.equal([1, 2]);
widget.destroy();
});
/**
* test_author_windy
**/
it("getValue", function () {
var widget = BI.Test.createWidget({
type: "bi.multi_select_no_bar_combo",
width: 220,
itemsCreator: _itemsCreator,
value: [1, 2, 3]
});
expect(widget.getValue()).to.deep.equal([1, 2, 3]);
widget.destroy();
});
/**
* test_author_windy
**/
it("点选选值", function (done) {
var widget = BI.Test.createWidget({
type: "bi.multi_select_no_bar_combo",
width: 220,
itemsCreator: _itemsCreator
});
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();
});
// 取消勾选1、2
BI.delay(function () {
BI.each(itemSelectorGetter([1,2]), function (idx, selector) {
widget.element.find(selector).click();
});
expect(widget.getValue()).to.deep.equal([2]);
widget.destroy();
done();
}, 300);
}, 300);
});
/**
* test_author_windy
**/
it("搜索选值", function (done) {
var widget = BI.Test.createWidget({
type: "bi.multi_select_no_bar_combo",
width: 220,
itemsCreator: _itemsCreator
});
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([2, 12]);
widget.destroy();
done();
});
});
});
});
});
/**
* test_author_windy
**/
it("查看已选", function (done) {
var widget = BI.Test.createWidget({
type: "bi.multi_select_no_bar_combo",
width: 220,
itemsCreator: function (op, callback) {
callback(items);
},
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);
});
});
/**
* test_author_windy
**/
it("setValue", function () {
var widget = BI.Test.createWidget({
type: "bi.multi_select_insert_no_bar_combo",
width: 220,
itemsCreator: _itemsCreator
});
widget.setValue([1, 2]);
expect(widget.getValue()).to.deep.equal([1, 2]);
widget.destroy();
});
/**
* test_author_windy
**/
it("getValue", function () {
var widget = BI.Test.createWidget({
type: "bi.multi_select_insert_no_bar_combo",
width: 220,
itemsCreator: _itemsCreator,
value: [1, 2, 3]
});
expect(widget.getValue()).to.deep.equal([1, 2, 3]);
widget.destroy();
});
/**
* test_author_windy
**/
it("点选选值1", function (done) {
var widget = BI.Test.createWidget({
type: "bi.multi_select_insert_no_bar_combo",
width: 220,
itemsCreator: _itemsCreator
});
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();
});
// 取消勾选1、2、3
BI.delay(function () {
BI.each(itemSelectorGetter([1,2]), function (idx, selector) {
widget.element.find(selector).click();
});
expect(widget.getValue()).to.deep.equal([2]);
widget.destroy();
done();
}, 300);
}, 300);
});
/**
* test_author_windy
**/
it("搜索选值1", function (done) {
var widget = BI.Test.createWidget({
type: "bi.multi_select_insert_no_bar_combo",
width: 220,
itemsCreator: _itemsCreator
});
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([2, 12]);
widget.destroy();
done();
});
});
});
});
});
/**
* test_author_windy
**/
it("新增值1", function (done) {
var widget = BI.Test.createWidget({
type: "bi.multi_select_insert_no_bar_combo",
width: 220,
itemsCreator: _itemsCreator
});
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"), "z", 50, function () {
BI.nextTick(function () {
widget.element.find(".bi-text-button:contains(+点击新增\"z\")").click();
expect(widget.getValue()).to.deep.equal(["z"]);
widget.destroy();
done();
});
});
});
});
});
/**
* test_author_windy
**/
it("查看已选1", function (done) {
var widget = BI.Test.createWidget({
type: "bi.multi_select_insert_no_bar_combo",
width: 220,
itemsCreator: _itemsCreator,
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);
});
});
});

121
src/widget/singleselect/__test__/singleselect.insert.combo.test.js

@ -0,0 +1,121 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/3/5
*/
describe("single_select_insert_combo", function () {
var items = BI.map(BI.makeArray(100, null), function(idx, v) {
return {
text: idx,
value: idx,
title: idx
};
});
var itemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) {
return ".bi-single-select-popup-view .bi-loader .bi-button-group .bi-single-select-radio-item:nth-child(" + num + ")";
});
};
var searchItemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) {
return ".bi-single-select-search-pane .bi-loader .bi-button-group .bi-single-select-radio-item:nth-child(" + num + ")";
});
};
/**
* test_author_windy
**/
it("setValue", function () {
var widget = BI.Test.createWidget({
type: "bi.single_select_insert_combo",
width: 220,
itemsCreator: function (op, callback) {
callback(items);
}
});
widget.setValue(1);
expect(widget.getValue()).to.equal(1);
widget.destroy();
});
/**
* test_author_windy
**/
it("getValue", function () {
var widget = BI.Test.createWidget({
type: "bi.single_select_insert_combo",
width: 220,
itemsCreator: function (op, callback) {
callback(items);
},
value: 1
});
expect(widget.getValue()).to.equal(1);
widget.destroy();
});
/**
* test_author_windy
**/
it("点选选值", function (done) {
var start = BI.getTime();
var widget = BI.Test.createWidget({
type: "bi.single_select_insert_combo",
width: 220,
itemsCreator: function (op, callback) {
callback({
items: items,
hasNext: false
});
}
});
widget.populate();
widget.element.find(".bi-single-select-trigger").click();
// 为什么要delay 300呢,因为按钮有debounce
BI.delay(function () {
// 点选1
BI.each(itemSelectorGetter([1]), function (idx, selector) {
widget.element.find(selector).click();
});
expect(widget.getValue()).to.equal(0);
widget.destroy();
done();
}, 300);
});
/**
* test_author_windy
**/
it("搜索选值", function (done) {
var widget = BI.Test.createWidget({
type: "bi.single_select_insert_combo",
width: 220,
itemsCreator: function (op, callback) {
callback({
items: items,
hasNext: false
});
}
});
BI.nextTick(function () {
widget.element.find(".bi-single-select-trigger .tip-text-style").click();
// 这边为啥要加呢,因为input的setValue中有nextTick
BI.nextTick(function () {
BI.Test.triggerKeyDown(widget.element.find(".bi-single-select-trigger .bi-input"), "2", 50, function () {
BI.nextTick(function () {
BI.each(searchItemSelectorGetter([3]), function (idx, selector) {
widget.element.find(selector).click();
});
expect(widget.getValue()).to.equal(2);
widget.destroy();
done();
});
});
});
});
});
});
Loading…
Cancel
Save