diff --git a/src/case/colorchooser/__test__/colorchooser.test.js b/src/case/colorchooser/__test__/colorchooser.test.js new file mode 100644 index 000000000..b845814e0 --- /dev/null +++ b/src/case/colorchooser/__test__/colorchooser.test.js @@ -0,0 +1,39 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/3 + */ + +describe("color_chooser_test", function () { + + /** + * test_author_windy + **/ + it("setValue", function () { + var widget = BI.Test.createWidget({ + type: "bi.color_chooser", + height: 24 + }); + widget.setValue("#69821b"); + expect(widget.getValue()).to.equal("#69821b"); + widget.destroy(); + }); + + /** + * test_author_windy + **/ + it("点选选值", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.color_chooser", + height: 24 + }); + widget.element.find(".bi-color-chooser-trigger").click(); + BI.delay(function () { + // 等300ms, button有debounce + widget.element.find(".bi-color-picker .bi-color-picker-button:nth-child(3)").click(); + expect(widget.getValue()).to.equal("#e5e5e5"); + widget.destroy(); + done(); + }, 300); + }); +}); \ No newline at end of file diff --git a/src/case/combo/icontextvaluecombo/__test__/combo.icontextvalue.test.js b/src/case/combo/icontextvaluecombo/__test__/combo.icontextvalue.test.js index e53e81070..e3450ae7c 100644 --- a/src/case/combo/icontextvaluecombo/__test__/combo.icontextvalue.test.js +++ b/src/case/combo/icontextvaluecombo/__test__/combo.icontextvalue.test.js @@ -31,12 +31,13 @@ describe("icontextvaluecombo", function () { }); combo.setValue(2); expect(combo.getValue()[0]).to.equal(2); + combo.destroy(); }); /** * test_author_windy */ - it("测试populate", function (done) { + it("测试populate", function () { var combo = BI.Test.createWidget({ type: "bi.text_value_combo", text: "默认值", @@ -58,7 +59,7 @@ describe("icontextvaluecombo", function () { }]); combo.setValue(2); expect(combo.getValue()[0]).to.equal(2); - done(); + combo.destroy(); }); }); diff --git a/src/case/combo/searchtextvaluecombo/__test__/combo.searchtextvaluecombo.test.js b/src/case/combo/searchtextvaluecombo/__test__/combo.searchtextvaluecombo.test.js new file mode 100644 index 000000000..47390ba16 --- /dev/null +++ b/src/case/combo/searchtextvaluecombo/__test__/combo.searchtextvaluecombo.test.js @@ -0,0 +1,90 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/3 + */ + +describe("search_text_value_combo", function () { + + var items = BI.map(BI.makeArray(100, null), function(idx, v) { + return { + text: idx, + value: idx, + title: idx + }; + }); + + /** + * test_author_windy + **/ + it("setValue", function () { + var widget = BI.Test.createWidget({ + type: "bi.search_text_value_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.search_text_value_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.search_text_value_combo", + width: 220, + items: items + }); + widget.element.find(".bi-search-text-value-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); + }); + + /** + * test_author_windy + **/ + it("搜索选值", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.search_text_value_combo", + width: 220, + items: items + }); + BI.nextTick(function () { + widget.element.find(".bi-search-text-value-trigger .tip-text-style").click(); + // 这边为啥要加呢,因为input的setValue中有nextTick + BI.nextTick(function () { + BI.Test.triggerKeyDown(widget.element.find(".bi-search-text-value-trigger .bi-input"), "2", 50, function () { + BI.nextTick(function () { + widget.element.find(".bi-search-text-value-popup .bi-single-select-item").click(); + expect(widget.getValue()[0]).to.deep.equal(2); + widget.destroy(); + done(); + }); + }); + }); + }); + }); +}); + diff --git a/src/case/combo/textvaluecombo/__test__/combo.textvalue.test.js b/src/case/combo/textvaluecombo/__test__/combo.textvalue.test.js index 0166958fd..5a90598f7 100644 --- a/src/case/combo/textvaluecombo/__test__/combo.textvalue.test.js +++ b/src/case/combo/textvaluecombo/__test__/combo.textvalue.test.js @@ -31,12 +31,13 @@ describe("textvaluecombo", function () { }); combo.setValue(2); expect(combo.getValue()[0]).to.equal(2); + combo.destroy(); }); /** * test_author_windy */ - it("测试populate", function (done) { + it("测试populate", function () { var combo = BI.Test.createWidget({ type: "bi.text_value_combo", text: "默认值", @@ -58,7 +59,7 @@ describe("textvaluecombo", function () { }]); combo.setValue(2); expect(combo.getValue()[0]).to.equal(2); - done(); + combo.destroy(); }); /** @@ -86,12 +87,13 @@ describe("textvaluecombo", function () { }); combo.setValue(2); expect(combo.getValue()[0]).to.equal(2); + combo.destroy(); }); /** * test_author_windy */ - it("测试small_populate", function (done) { + it("测试small_populate", function () { var combo = BI.Test.createWidget({ type: "bi.small_text_value_combo", text: "默认值", @@ -113,6 +115,6 @@ describe("textvaluecombo", function () { }]); combo.setValue(2); expect(combo.getValue()[0]).to.equal(2); - done(); + combo.destroy(); }); }); \ No newline at end of file diff --git a/src/component/allvaluechooser/__test__/combo.allvaluechooser.test.js b/src/component/allvaluechooser/__test__/combo.allvaluechooser.test.js new file mode 100644 index 000000000..6c4030c1c --- /dev/null +++ b/src/component/allvaluechooser/__test__/combo.allvaluechooser.test.js @@ -0,0 +1,67 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/4 + */ + +describe("all_value_chooser_combo", 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.all_value_chooser_combo", + width: 220, + itemsCreator: function (op, callback) { + callback(items); + } + }); + widget.setValue([1, 2]); + expect(widget.getValue()).to.deep.equal([1, 2]); + widget.destroy(); + }); + + /** + * test_author_windy + **/ + it("点选选值", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.all_value_chooser_combo", + width: 220, + itemsCreator: function (op, callback) { + callback(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(); + }); + expect(widget.getValue()).to.deep.equal([0, 1, 2]); + done(); + }, 300); + }); +}); \ No newline at end of file diff --git a/src/component/allvaluemultitextvaluecombo/__test__/allvalue.multitextvalue.combo.test.js b/src/component/allvaluemultitextvaluecombo/__test__/allvalue.multitextvalue.combo.test.js new file mode 100644 index 000000000..f4e86de78 --- /dev/null +++ b/src/component/allvaluemultitextvaluecombo/__test__/allvalue.multitextvalue.combo.test.js @@ -0,0 +1,30 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/4 + */ + +describe("all_value_multi_text_value_combo", function () { + + var items = BI.map(BI.makeArray(1000, null), function(idx, v) { + return { + text: idx, + value: idx, + title: idx + }; + }); + + /** + * test_author_windy + **/ + it("setValue", function () { + var widget = BI.Test.createWidget({ + type: "bi.all_value_multi_text_value_combo", + width: 220, + items: items + }); + widget.setValue([1, 2]); + expect(widget.getValue()).to.deep.equal([1, 2]); + widget.destroy(); + }); +}); \ No newline at end of file