diff --git a/src/widget/intervalslider/__test__/accuratecalculation.test.js b/src/widget/intervalslider/__test__/accuratecalculation.test.js new file mode 100644 index 0000000000..8592b5858d --- /dev/null +++ b/src/widget/intervalslider/__test__/accuratecalculation.test.js @@ -0,0 +1,49 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/5/14 + */ +describe("accuratecalculation", function () { + + /** + * test_author_windy + */ + it("add", function () { + var calculation = new BI.AccurateCalculationModel(); + + + }); + + /** + * test_author_windy + */ + it("sub", function () { + var calculation = new BI.AccurateCalculationModel(); + expect(calculation.accurateSubtraction(0.124, 2345.678)).to.equal(-2345.554); + expect(calculation.accurateSubtraction(-0.124, -2345.678)).to.equal(2345.554); + expect(calculation.accurateSubtraction(0.124, -2345.678)).to.equal(2345.802); + expect(calculation.accurateSubtraction(-2345.678, 0.124)).to.equal(-2345.802); + + }); + + /** + * test_author_windy + */ + it("mul", function () { + var calculation = new BI.AccurateCalculationModel(); + expect(calculation.accurateSubtraction(0.124, 2345.678)).to.equal(-2345.554); + expect(calculation.accurateSubtraction(-0.124, -2345.678)).to.equal(2345.554); + expect(calculation.accurateSubtraction(0.124, -2345.678)).to.equal(2345.802); + expect(calculation.accurateSubtraction(-2345.678, 0.124)).to.equal(-2345.802); + + }); + + /** + * test_author_windy + */ + it("div", function () { + var calculation = new BI.AccurateCalculationModel(); + + + }); +}); \ No newline at end of file diff --git a/src/widget/multilayerselecttree/multilayerselecttree.popup.js b/src/widget/multilayerselecttree/multilayerselecttree.popup.js index 9f8dd961a0..dd29ce6e9e 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.popup.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.popup.js @@ -15,7 +15,8 @@ BI.MultiLayerSelectTreePopup = BI.inherit(BI.Widget, { itemsCreator: BI.emptyFn, items: [], value: "", - onLoaded: BI.emptyFn + onLoaded: BI.emptyFn, + minHeight: 240 }); }, @@ -54,6 +55,8 @@ BI.MultiLayerSelectTreePopup = BI.inherit(BI.Widget, { this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, function () { self.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE); }); + + this.tree.css("min-height", o.minHeight - 10); }, getValue: function () { diff --git a/src/widget/multilayersingletree/multilayersingletree.popup.js b/src/widget/multilayersingletree/multilayersingletree.popup.js index 7623110b4a..160c67a3c7 100644 --- a/src/widget/multilayersingletree/multilayersingletree.popup.js +++ b/src/widget/multilayersingletree/multilayersingletree.popup.js @@ -14,7 +14,8 @@ BI.MultiLayerSingleTreePopup = BI.inherit(BI.Widget, { isDefaultInit: false, itemsCreator: BI.emptyFn, items: [], - onLoaded: BI.emptyFn + onLoaded: BI.emptyFn, + minHeight: 240 }); }, @@ -53,6 +54,8 @@ BI.MultiLayerSingleTreePopup = BI.inherit(BI.Widget, { this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, function () { self.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE); }); + + this.tree.css("min-height", o.minHeight - 10); }, getValue: function () { diff --git a/src/widget/multiselectlist/__test__/multiselect.insert.nobar.test.js b/src/widget/multiselectlist/__test__/multiselect.insert.nobar.test.js new file mode 100644 index 0000000000..e5bdd98f77 --- /dev/null +++ b/src/widget/multiselectlist/__test__/multiselect.insert.nobar.test.js @@ -0,0 +1,130 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/6/2 + */ +describe("multi_list_insert_no_bar_pane", 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 ".popup-multi-select-list .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_insert_no_bar_list", + width: 220, + itemsCreator: function (op, callback) { + callback(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("点选选值", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.multi_select_insert_no_bar_list", + width: 220, + itemsCreator: function (op, callback) { + callback({ + items: items, + hasNext: false + }); + } + }); + widget.populate(); + BI.nextTick(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,3]), function (idx, selector) { + widget.element.find(selector).click(); + }); + var value = widget.getValue(); + delete value.assist; + expect(value).to.deep.equal([]); + widget.destroy(); + done(); + }, 300); + }); + }); + + /** + * test_author_windy + **/ + it("搜索选值", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.multi_select_insert_no_bar_list", + width: 220, + itemsCreator: function (op, callback) { + if (op.keywords) { + callback({ + items: [{ + text: "2", + value: "2", + title: "2" + }, { + text: "12", + value: "12", + title: "12" + }], + hasNext: false + }); + } else { + callback({ + items: items, + hasNext: false + }); + } + } + }); + widget.element.find(".bi-water-mark").click(); + // 这边为啥要加呢,因为input的setValue中有nextTick + BI.nextTick(function () { + BI.Test.triggerKeyDown(widget.element.find(".bi-input"), "2", 50, function () { + BI.nextTick(function () { + BI.each(searchItemSelectorGetter([1,2]), function (idx, selector) { + widget.element.find(selector).click(); + }); + var value = widget.getValue(); + delete value.assist; + expect(value).to.deep.equal(["2", "12"]); + widget.destroy(); + done(); + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/src/widget/multiselectlist/__test__/multiselectlist.insert.test.js b/src/widget/multiselectlist/__test__/multiselectlist.insert.test.js new file mode 100644 index 0000000000..729791ce95 --- /dev/null +++ b/src/widget/multiselectlist/__test__/multiselectlist.insert.test.js @@ -0,0 +1,170 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/6/2 + */ +describe("multi_list_insert_pane", 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 ".popup-multi-select-list .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_insert_list", + width: 220, + itemsCreator: function (op, callback) { + callback(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("点选选值", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.multi_select_insert_list", + width: 220, + itemsCreator: function (op, callback) { + callback({ + items: items, + hasNext: false + }); + } + }); + widget.populate(); + BI.nextTick(function () { + // 点选1、2、3 + BI.each(itemSelectorGetter([1,2,3]), function (idx, selector) { + widget.element.find(selector).click(); + }); + // 点全选 + widget.element.find(".popup-multi-select-list .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(); + delete value.assist; + expect(value).to.deep.equal({ + type: 2, + value: [0, 1, 2] + }); + widget.destroy(); + done(); + }, 300); + }); + }); + + /** + * test_author_windy + **/ + it("搜索选值", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.multi_select_insert_list", + width: 220, + itemsCreator: function (op, callback) { + if (op.keywords) { + callback({ + items: [{ + text: "2", + value: "2", + title: "2" + }, { + text: "12", + value: "12", + title: "12" + }], + hasNext: false + }); + } else { + callback({ + items: items, + hasNext: false + }); + } + } + }); + widget.element.find(".bi-water-mark").click(); + // 这边为啥要加呢,因为input的setValue中有nextTick + BI.nextTick(function () { + BI.Test.triggerKeyDown(widget.element.find(".bi-input"), "2", 50, function () { + BI.nextTick(function () { + BI.each(searchItemSelectorGetter([1,2]), function (idx, selector) { + widget.element.find(selector).click(); + }); + var value = widget.getValue(); + delete value.assist; + expect(value).to.deep.equal({ + type: 1, + value: ["2", "12"] + }); + widget.destroy(); + done(); + }); + }); + }); + }); + + /** + * test_author_windy + **/ + it("新增值", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.multi_select_insert_list", + width: 220, + itemsCreator: function (op, callback) { + callback({ + items: items, + hasNext: false + }); + } + }); + BI.nextTick(function () { + // 这边为啥要加呢,因为input的setValue中有nextTick + BI.Test.triggerKeyDown(widget.element.find(".bi-input"), "z", 50, function () { + BI.nextTick(function () { + widget.element.find(".bi-text-button:contains(+点击新增\"z\")").click(); + var value = widget.getValue(); + delete value.assist; + expect(value).to.deep.equal({ + type: 1, + value: ["z"] + }); + widget.destroy(); + done(); + }); + }); + }); + }); +}); \ No newline at end of file