From 04fbb3c090dcb5f603e2c13d4411129801c5fc59 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 24 Sep 2019 15:52:34 +0800 Subject: [PATCH] =?UTF-8?q?BI-52072=20&&=20BI-52369=20&&=20BI-52345=20test?= =?UTF-8?q?:=20widget=E5=8D=95=E6=B5=8B=E7=BB=BF=E5=8C=96=20&&=20datepane?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=20&&=20button=E7=9A=84bubble?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 4 + src/base/single/button/button.basic.js | 2 + src/case/colorchooser/colorchooser.js | 4 +- src/case/colorchooser/colorchooser.trigger.js | 2 +- .../colorchooser/colorchooser.trigger.long.js | 2 +- .../combo.valuechooser.insert.test.js | 193 ++++++++++++++++++ .../__test__/combo.valuechooser.test.js | 163 +++++++++++++++ .../__test__/pane.valuechooser.test.js | 111 ++++++++++ src/widget/datepane/datepane.js | 1 + 9 files changed, 478 insertions(+), 4 deletions(-) create mode 100644 src/component/valuechooser/__test__/combo.valuechooser.insert.test.js create mode 100644 src/component/valuechooser/__test__/combo.valuechooser.test.js create mode 100644 src/component/valuechooser/__test__/pane.valuechooser.test.js diff --git a/changelog.md b/changelog.md index 0d84d3b1b..fc74c1c3c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,8 @@ # 更新日志 +2.0(2019-09) +- button的bubble创建的popup在收起的时候会destroy +- 修复了dynamic_date_pane在切换静态时间和动态时间的时候不会发事件的问题 + 2.0(2019-08) - 修复valueChooser系列不支持value属性的问题 - 更新了若干icon-font的样式 diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index ae6ee758f..d19d20412 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -229,6 +229,8 @@ BI.BasicButton = BI.inherit(BI.Single, { el: { type: "bi.bubble_combo", trigger: "", + // bubble的提示不需要一直存在在界面上 + destroyWhenHide: true, ref: function () { self.combo = this; }, diff --git a/src/case/colorchooser/colorchooser.js b/src/case/colorchooser/colorchooser.js index a753e076e..9414ab78d 100644 --- a/src/case/colorchooser/colorchooser.js +++ b/src/case/colorchooser/colorchooser.js @@ -30,8 +30,8 @@ BI.ColorChooser = BI.inherit(BI.Widget, { ref: function (_ref) { self.trigger = _ref; }, - width: o.width, - height: o.height + width: o.width - 2, + height: o.height - 2 }, o.el), popup: { el: BI.extend({ diff --git a/src/case/colorchooser/colorchooser.trigger.js b/src/case/colorchooser/colorchooser.trigger.js index 9cd3d2f09..07101ae3a 100644 --- a/src/case/colorchooser/colorchooser.trigger.js +++ b/src/case/colorchooser/colorchooser.trigger.js @@ -11,7 +11,7 @@ BI.ColorChooserTrigger = BI.inherit(BI.Trigger, { var conf = BI.ColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger bi-border", - height: 24 + height: 22 }); }, diff --git a/src/case/colorchooser/colorchooser.trigger.long.js b/src/case/colorchooser/colorchooser.trigger.long.js index 946fe67bf..0c947bd1d 100644 --- a/src/case/colorchooser/colorchooser.trigger.long.js +++ b/src/case/colorchooser/colorchooser.trigger.long.js @@ -11,7 +11,7 @@ BI.LongColorChooserTrigger = BI.inherit(BI.Trigger, { var conf = BI.LongColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger bi-border", - height: 24 + height: 22 }); }, diff --git a/src/component/valuechooser/__test__/combo.valuechooser.insert.test.js b/src/component/valuechooser/__test__/combo.valuechooser.insert.test.js new file mode 100644 index 000000000..e3fbc10d4 --- /dev/null +++ b/src/component/valuechooser/__test__/combo.valuechooser.insert.test.js @@ -0,0 +1,193 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/23 + */ +describe("value_chooser_insert_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.value_chooser_insert_combo", + 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("getValue", function () { + var widget = BI.Test.createWidget({ + type: "bi.value_chooser_insert_combo", + width: 220, + itemsCreator: function (op, callback) { + callback(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.value_chooser_insert_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(); + }); + // 点全选 + 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(); + }); + expect(widget.getValue()).to.deep.equal({ + type: 2, + value: [0, 1, 2] + }); + widget.destroy(); + done(); + }, 300); + }, 300); + }); + + /** + * test_author_windy + **/ + it("搜索选值", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.value_chooser_insert_combo", + width: 220, + itemsCreator: function (op, callback) { + callback(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.value_chooser_insert_combo", + width: 220, + itemsCreator: function (op, callback) { + callback(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"), "z", 50, function () { + BI.nextTick(function () { + widget.element.find(".bi-text-button:contains(+点击新增\"z\")").click(); + expect(widget.getValue()).to.deep.equal({ + type: 1, + value: ["z"] + }); + widget.destroy(); + done(); + }); + }); + }); + }); + }); + + /** + * test_author_windy + **/ + it("查看已选", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.value_chooser_insert_combo", + width: 220, + itemsCreator: function (op, callback) { + callback(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); + }); + }); +}); \ No newline at end of file diff --git a/src/component/valuechooser/__test__/combo.valuechooser.test.js b/src/component/valuechooser/__test__/combo.valuechooser.test.js new file mode 100644 index 000000000..bf21ed0e6 --- /dev/null +++ b/src/component/valuechooser/__test__/combo.valuechooser.test.js @@ -0,0 +1,163 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/23 + */ +describe("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.value_chooser_combo", + 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("getValue", function () { + var widget = BI.Test.createWidget({ + type: "bi.value_chooser_combo", + width: 220, + itemsCreator: function (op, callback) { + callback(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.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(); + }); + // 点全选 + 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(); + }); + expect(widget.getValue()).to.deep.equal({ + type: 2, + value: [0, 1, 2] + }); + widget.destroy(); + done(); + }, 300); + }, 300); + }); + + /** + * test_author_windy + **/ + it("搜索选值", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.value_chooser_combo", + width: 220, + itemsCreator: function (op, callback) { + callback(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.value_chooser_combo", + width: 220, + itemsCreator: function (op, callback) { + callback(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); + }); + }); +}); \ No newline at end of file diff --git a/src/component/valuechooser/__test__/pane.valuechooser.test.js b/src/component/valuechooser/__test__/pane.valuechooser.test.js new file mode 100644 index 000000000..76e939071 --- /dev/null +++ b/src/component/valuechooser/__test__/pane.valuechooser.test.js @@ -0,0 +1,111 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/23 + */ + +describe("value_chooser_pane", 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 ".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.value_chooser_pane", + 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.value_chooser_pane", + width: 220, + items: items + }); + 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(); + }); + expect(widget.getValue()).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.value_chooser_pane", + width: 220, + itemsCreator: function (op, callback) { + callback(items); + } + }); + 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(); + }); + expect(widget.getValue()).to.deep.equal({ + type: 1, + value: [2, 12] + }); + widget.destroy(); + done(); + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/src/widget/datepane/datepane.js b/src/widget/datepane/datepane.js index 359aa7d6d..8c60da784 100644 --- a/src/widget/datepane/datepane.js +++ b/src/widget/datepane/datepane.js @@ -44,6 +44,7 @@ BI.DynamicDatePane = BI.inherit(BI.Widget, { default: break; } + self.fireEvent("EVENT_CHANGE"); } }], ref: function () {