From afe985c9953bc1b6e3bee290ec580f9010ae2612 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Wed, 4 Sep 2019 19:37:14 +0800 Subject: [PATCH] =?UTF-8?q?BI-51100=20test:=20=E6=96=B0=E5=A2=9E=E5=8D=95?= =?UTF-8?q?=E6=B5=8B=20&&=20=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/2.0/fineui.ie.js | 5 - dist/2.0/fineui.js | 5 - dist/bundle.ie.js | 5 - dist/bundle.js | 5 - dist/fineui.ie.js | 5 - dist/fineui.js | 5 - dist/fineui_without_jquery_polyfill.js | 5 - dist/widget.js | 5 - karma.conf.js | 1 + .../downlist/__test__/combo.downlist.test.js | 19 +++ .../__test__/dynamicdate.combo.test.js | 119 ++++++++++++++++++ src/widget/dynamicdate/dynamicdate.combo.js | 5 - test/utils.js | 25 ++++ 13 files changed, 164 insertions(+), 45 deletions(-) create mode 100644 src/widget/downlist/__test__/combo.downlist.test.js create mode 100644 src/widget/dynamicdate/__test__/dynamicdate.combo.test.js diff --git a/dist/2.0/fineui.ie.js b/dist/2.0/fineui.ie.js index 2167c30fd..f85f09335 100644 --- a/dist/2.0/fineui.ie.js +++ b/dist/2.0/fineui.ie.js @@ -64713,11 +64713,6 @@ BI.extend(BI.DynamicDateCard, { self.combo.showView(); } } - }, { - eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } }, { eventName: BI.DynamicDateTrigger.EVENT_FOCUS, action: function () { diff --git a/dist/2.0/fineui.js b/dist/2.0/fineui.js index 42ef7cbc9..5c832fa5c 100644 --- a/dist/2.0/fineui.js +++ b/dist/2.0/fineui.js @@ -65117,11 +65117,6 @@ BI.extend(BI.DynamicDateCard, { self.combo.showView(); } } - }, { - eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } }, { eventName: BI.DynamicDateTrigger.EVENT_FOCUS, action: function () { diff --git a/dist/bundle.ie.js b/dist/bundle.ie.js index 2167c30fd..f85f09335 100644 --- a/dist/bundle.ie.js +++ b/dist/bundle.ie.js @@ -64713,11 +64713,6 @@ BI.extend(BI.DynamicDateCard, { self.combo.showView(); } } - }, { - eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } }, { eventName: BI.DynamicDateTrigger.EVENT_FOCUS, action: function () { diff --git a/dist/bundle.js b/dist/bundle.js index 42ef7cbc9..5c832fa5c 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -65117,11 +65117,6 @@ BI.extend(BI.DynamicDateCard, { self.combo.showView(); } } - }, { - eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } }, { eventName: BI.DynamicDateTrigger.EVENT_FOCUS, action: function () { diff --git a/dist/fineui.ie.js b/dist/fineui.ie.js index a7d14049c..4fd2feb94 100644 --- a/dist/fineui.ie.js +++ b/dist/fineui.ie.js @@ -64958,11 +64958,6 @@ BI.extend(BI.DynamicDateCard, { self.combo.showView(); } } - }, { - eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } }, { eventName: BI.DynamicDateTrigger.EVENT_FOCUS, action: function () { diff --git a/dist/fineui.js b/dist/fineui.js index de2ffea05..5b902a9c7 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -65362,11 +65362,6 @@ BI.extend(BI.DynamicDateCard, { self.combo.showView(); } } - }, { - eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } }, { eventName: BI.DynamicDateTrigger.EVENT_FOCUS, action: function () { diff --git a/dist/fineui_without_jquery_polyfill.js b/dist/fineui_without_jquery_polyfill.js index 055418cf1..549d0671b 100644 --- a/dist/fineui_without_jquery_polyfill.js +++ b/dist/fineui_without_jquery_polyfill.js @@ -47661,11 +47661,6 @@ BI.extend(BI.DynamicDateCard, { self.combo.showView(); } } - }, { - eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } }, { eventName: BI.DynamicDateTrigger.EVENT_FOCUS, action: function () { diff --git a/dist/widget.js b/dist/widget.js index 637a78e70..180f82c97 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -2771,11 +2771,6 @@ BI.extend(BI.DynamicDateCard, { self.combo.showView(); } } - }, { - eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } }, { eventName: BI.DynamicDateTrigger.EVENT_FOCUS, action: function () { diff --git a/karma.conf.js b/karma.conf.js index 398ac8fa9..ac795ceac 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -18,6 +18,7 @@ module.exports = function (config) { "src/css/theme/**/*.css", "src/css/base/**/*.css", "src/css/widget/**/*.css", + "public/css/app.css", "src/core/foundation.js", "src/core/lodash.js", "src/core/base.js", diff --git a/src/widget/downlist/__test__/combo.downlist.test.js b/src/widget/downlist/__test__/combo.downlist.test.js new file mode 100644 index 000000000..6ef031422 --- /dev/null +++ b/src/widget/downlist/__test__/combo.downlist.test.js @@ -0,0 +1,19 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/3 + */ + +describe("DownListCombo", function () { + + /** + * test_author_windy + */ + it("defaultValue", function () { + var datePane = BI.Test.createWidget({ + type: "bi.down_list_combo", + adjustLength: 10, + items: [[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":12},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}],[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":11},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}]] + }); + }); +}); \ No newline at end of file diff --git a/src/widget/dynamicdate/__test__/dynamicdate.combo.test.js b/src/widget/dynamicdate/__test__/dynamicdate.combo.test.js new file mode 100644 index 000000000..eb6ff4062 --- /dev/null +++ b/src/widget/dynamicdate/__test__/dynamicdate.combo.test.js @@ -0,0 +1,119 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/4 + */ + +describe("DateCombo", function () { + + /** + * test_author_windy + */ + it("defaultValue", function () { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_combo", + value: { + type: 1, + value: { + year: 2018, + month: 2, + day: 23 + } + } + }); + expect(dateCombo.element.find(".bi-date-trigger .bi-label").text()).to.equal("2018-02-23"); + dateCombo.destroy(); + }); + + /** + * test_author_windy + */ + it("测试输入值收起下拉清空值下拉出现", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_combo", + width: 220, + height: 30, + value: { + type: 1, + value: { + year: 2018, + month: 2, + day: 23 + } + } + }); + BI.nextTick(function () { + dateCombo.element.find(".bi-date-trigger .bi-basic-button").click(); + // 输入8, 检查popup是否收起 + BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), "8", 56, function () { + BI.nextTick(function () { + expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").css("display")).to.equal("none"); + // 清空输入, 检查popup是否弹出 + BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), "", BI.KeyCode.BACKSPACE, function () { + BI.nextTick(function () { + expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").css("display")).to.equal("block"); + dateCombo.destroy(); + done(); + }); + }); + }); + }); + }); + + }); + + /** + * test_author_windy + */ + it("trigger的confirm-下拉面板选值confirm", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_combo", + width: 220, + height: 30 + }); + // 点击日期,是否收起下拉 + dateCombo.element.find(".bi-date-trigger .bi-basic-button").click(); + BI.nextTick(function () { + dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(5)").parent().click(); + expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").css("display")).to.equal("none"); + dateCombo.destroy(); + done(); + }) + + }); + + + /** + * test_author_windy + */ + it("trigger的输入日期后confirm", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_date_combo", + width: 220, + height: 30, + value: { + type: 1, + value: { + year: 2018, + month: 2, + day: 23 + } + } + }); + BI.nextTick(function () { + dateCombo.element.find(".bi-date-trigger .bi-basic-button").click(); + BI.nextTick(function () { + var input = dateCombo.element.find(".bi-date-trigger .bi-input"); + input.val("2017-1-1"); + BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), null, BI.KeyCode.ENTER, function () { + BI.delay(function () { + expect(dateCombo.element.find(".bi-date-trigger .bi-text-button").text()).to.equal("2017-01-01"); + dateCombo.destroy(); + done(); + }, 300); + }); + }); + }) + + }); +}); \ No newline at end of file diff --git a/src/widget/dynamicdate/dynamicdate.combo.js b/src/widget/dynamicdate/dynamicdate.combo.js index f2d9cda51..6ae285f5c 100644 --- a/src/widget/dynamicdate/dynamicdate.combo.js +++ b/src/widget/dynamicdate/dynamicdate.combo.js @@ -73,11 +73,6 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, { self.combo.showView(); } } - }, { - eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } }, { eventName: BI.DynamicDateTrigger.EVENT_FOCUS, action: function () { diff --git a/test/utils.js b/test/utils.js index 5de2d2005..cc83013cc 100644 --- a/test/utils.js +++ b/test/utils.js @@ -7,6 +7,31 @@ })); widget.element.appendTo("body"); return widget; + }, + + /** + * 模拟一次输入框的keydown事件 + */ + triggerKeyDown: function (element, value, keyCode, callback) { + // keydown + var e = $.Event("keydown"); + e.keyCode = keyCode; + element.trigger(e); + + // input + BI.isNotNull(value) && element.val(value); + var e1 = $.Event("input"); + e1.originalEvent = {}; + e1.keyCode = keyCode; + element.trigger(e1); + + // keyup 至少等300ms后触发 + BI.delay(function () { + var e2 = jQuery.Event("keyup"); + e2.keyCode = keyCode; + element.trigger(e2); + callback(); + }, 300); } }) })(); \ No newline at end of file