From edfd125b4083543ae0473d2b4f736b41df620ef7 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 17 Mar 2020 16:40:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-28235=20fix:=20timeCombo=20%M:%S?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + src/widget/time/__test__/time.combo.test.js | 23 +++++++++++++++++++++ src/widget/time/time.trigger.js | 18 ++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 6ece36e8e..5f35acd18 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-03) +- 修复了time_combo设置格式为%M:%S后value设置大于30分钟的值时标红的问题 - 复选下拉树系列展开节点性能优化 2.0(2020-02) diff --git a/src/widget/time/__test__/time.combo.test.js b/src/widget/time/__test__/time.combo.test.js index 3bc9d42fa..957be024e 100644 --- a/src/widget/time/__test__/time.combo.test.js +++ b/src/widget/time/__test__/time.combo.test.js @@ -168,4 +168,27 @@ describe("TimeCombo", function () { }) }); + + + /** + * test_author_windy + */ + it("测试%M:%S", function (done) { + var timeCombo = BI.Test.createWidget({ + type: "bi.time_combo", + width: 220, + height: 30, + format: "%M:%S", // mm:ss + value: { + hour: 12, + minute: 45, + second: 0 + }, + }); + BI.nextTick(function () { + expect(timeCombo.element.find(".bi-time-trigger .bi-label").text()).to.equal("45:00"); + timeCombo.destroy(); + done(); + }); + }); }); \ No newline at end of file diff --git a/src/widget/time/time.trigger.js b/src/widget/time/time.trigger.js index fc05620c4..037a03888 100644 --- a/src/widget/time/time.trigger.js +++ b/src/widget/time/time.trigger.js @@ -19,7 +19,8 @@ "%H:%M", // HH:mm "%M:%S" // mm:ss ], - DEFAULT_DATE_STRING: "2000-01-01" + DEFAULT_DATE_STRING: "2000-01-01", + DEFAULT_HOUR: "00" }, props: { @@ -135,11 +136,24 @@ _dateCheck: function (date) { var c = this._const; + var self = this; return BI.any(c.FORMAT_ARRAY, function (idx, format) { - return BI.print(BI.parseDateTime(c.DEFAULT_DATE_STRING + " " + date, c.COMPLETE_COMPARE_FORMAT), format) === date; + return BI.print(BI.parseDateTime(c.DEFAULT_DATE_STRING + " " + self._getCompleteHMS(date, format), c.COMPLETE_COMPARE_FORMAT), format) === date; }); }, + _getCompleteHMS: function (str, format) { + var c = this._const; + switch (format) { + case "%M:%S": + str = c.DEFAULT_HOUR + ":" + str; + break; + default: + break; + } + return str; + }, + _getTitle: function () { var storeValue = this.storeValue || {}; var date = BI.getDate(); From 5c09b2dc3da3adacbb1d02b74e5e2e4b313b396c Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 17 Mar 2020 16:42:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?KERNEL-3477=20test:=20=E5=8D=95=E6=B5=8B?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E7=8E=8753.2%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collection/__test__/collection.test.js | 38 +++++++++ src/base/layer/__test__/layer.popover.test.js | 33 ++++++++ .../single/iframe/__test__/iframe.test.js | 23 ++++++ src/base/single/img/__test__/img.test.js | 23 ++++++ src/base/single/link/__test__/link.test.js | 19 +++++ src/case/pager/__test__/pager.test.js | 81 +++++++++++++++++++ src/case/segment/__test__/segment.test.js | 33 ++++++++ 7 files changed, 250 insertions(+) create mode 100644 src/base/collection/__test__/collection.test.js create mode 100644 src/base/layer/__test__/layer.popover.test.js create mode 100644 src/base/single/iframe/__test__/iframe.test.js create mode 100644 src/base/single/img/__test__/img.test.js create mode 100644 src/base/single/link/__test__/link.test.js create mode 100644 src/case/pager/__test__/pager.test.js create mode 100644 src/case/segment/__test__/segment.test.js diff --git a/src/base/collection/__test__/collection.test.js b/src/base/collection/__test__/collection.test.js new file mode 100644 index 000000000..381735ac3 --- /dev/null +++ b/src/base/collection/__test__/collection.test.js @@ -0,0 +1,38 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/17 + */ + +describe("CollectionTest", function () { + + /** + * test_author_windy + */ + it("collection", function () { + var items = []; + var cellCount = 100; + for (var i = 0; i < cellCount; i++) { + items[i] = { + type: "bi.label", + text: i + }; + } + var grid = BI.Test.createWidget({ + type: "bi.collection_view", + width: 400, + height: 300, + items: items, + cellSizeAndPositionGetter: function (index) { + return { + x: index % 10 * 50, + y: Math.floor(index / 10) * 50, + width: 50, + height: 50 + }; + } + }); + // TODO 列表展示类控件不知道该测什么,先标记一下 + grid.destroy(); + }); +}); \ No newline at end of file diff --git a/src/base/layer/__test__/layer.popover.test.js b/src/base/layer/__test__/layer.popover.test.js new file mode 100644 index 000000000..1830744a8 --- /dev/null +++ b/src/base/layer/__test__/layer.popover.test.js @@ -0,0 +1,33 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/17 + */ + +describe("PopoverTest", function () { + + /** + * test_author_windy + */ + it("BarPopover", function (done) { + var id = BI.UUID(); + BI.Popovers.remove(id); + BI.Popovers.create(id, { + type: "bi.bar_popover", + size: "normal", + header: { + type: "bi.label", + text: "这个是header" + }, + body: { + type: "bi.label", + text: "这个是body" + } + }).open(id); + BI.delay(function () { + expect(BI.Widget._renderEngine.createElement("body").find(".bi-popup-view .bi-z-index-mask").length).to.equal(1); + BI.Popovers.remove(id); + done(); + }, 100); + }); +}); \ No newline at end of file diff --git a/src/base/single/iframe/__test__/iframe.test.js b/src/base/single/iframe/__test__/iframe.test.js new file mode 100644 index 000000000..8e99a48a0 --- /dev/null +++ b/src/base/single/iframe/__test__/iframe.test.js @@ -0,0 +1,23 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/17 + */ + +describe("IframeTest", function () { + + /** + * test_author_windy + */ + it("directionPager", function () { + var a = BI.Test.createWidget({ + type: "bi.iframe" + }); + a.setSrc("http://www.baidu.com"); + a.setName("testIFrame"); + expect(a.element.attr("src"), "http://www.baidu.com"); + expect(a.getSrc(), "http://www.baidu.com"); + expect(a.getName(), "testIFrame"); + a.destroy(); + }); +}); \ No newline at end of file diff --git a/src/base/single/img/__test__/img.test.js b/src/base/single/img/__test__/img.test.js new file mode 100644 index 000000000..d16ca92d8 --- /dev/null +++ b/src/base/single/img/__test__/img.test.js @@ -0,0 +1,23 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/17 + */ + +describe("ImgTest", function () { + + /** + * test_author_windy + */ + it("img", function () { + var a = BI.Test.createWidget({ + type: "bi.img", + iconWidth: 36, + iconHeight: 36 + }); + a.setSrc("test.png"); + expect(a.element.attr("src")).to.equal("test.png"); + expect(a.getSrc()).to.equal("test.png"); + a.destroy(); + }); +}); \ No newline at end of file diff --git a/src/base/single/link/__test__/link.test.js b/src/base/single/link/__test__/link.test.js new file mode 100644 index 000000000..e425cb44b --- /dev/null +++ b/src/base/single/link/__test__/link.test.js @@ -0,0 +1,19 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/17 + */ + +describe("LinkTest", function () { + + /** + * test_author_windy + */ + it("link", function () { + var a = BI.Test.createWidget({ + type: "bi.link" + }); + expect(a.element.is('a')).to.equal(true); + a.destroy(); + }); +}); \ No newline at end of file diff --git a/src/case/pager/__test__/pager.test.js b/src/case/pager/__test__/pager.test.js new file mode 100644 index 000000000..257e79272 --- /dev/null +++ b/src/case/pager/__test__/pager.test.js @@ -0,0 +1,81 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/17 + */ + +describe("PagerTest", function () { + + /** + * test_author_windy + */ + it("allCountPager", function () { + var a = BI.Test.createWidget({ + type: "bi.all_count_pager", + pages: 3, + curr: 1, + count: 1000 + }); + a.setCount(888); + expect(a.element.find(".row-count").text()).to.equal("888"); + a.setAllPages(777); + a.setValue(4); + expect(a.element.find(".bi-input").val()).to.equal("4"); + expect(a.getCurrentPage()).to.equal(4); + expect(a.hasPrev()).to.equal(false); + expect(a.hasNext()).to.equal(true); + a.populate(); + expect(a.element.find(".bi-input").val()).to.equal("4"); + a.setPagerVisible(false); + expect(a.element.find(".bi-pager").css("display")).to.equal("none"); + a.destroy(); + }); + + + /** + * test_author_windy + */ + it("directionPager", function () { + var a = BI.Test.createWidget({ + type: "bi.direction_pager", + horizontal: { + pages: false, // 总页数 + curr: 1, // 初始化当前页, pages为数字时可用 + + hasPrev: function (v) { + return v > 1; + }, + hasNext: function () { + return true; + }, + firstPage: 1 + }, + vertical: { + pages: false, // 总页数 + curr: 1, // 初始化当前页, pages为数字时可用 + + hasPrev: function (v) { + return v > 1; + }, + hasNext: function () { + return true; + }, + firstPage: 1 + } + }); + a.populate(); + a.setVPage(2); + expect(a.getVPage()).to.equal(1); + a.setHPage(2); + expect(a.getHPage()).to.equal(1); + expect(a.hasVNext()).to.equal(true); + expect(a.hasHNext()).to.equal(true); + expect(a.hasVPrev()).to.equal(false); + expect(a.hasHPrev()).to.equal(false); + a.setHPagerVisible(false) + a.setVPagerVisible(false) + expect(a.element.find(".bi-pager").css("display")).to.equal("none"); + a.clear(); + a.destroy(); + }); +}); \ No newline at end of file diff --git a/src/case/segment/__test__/segment.test.js b/src/case/segment/__test__/segment.test.js new file mode 100644 index 000000000..0b45ab53a --- /dev/null +++ b/src/case/segment/__test__/segment.test.js @@ -0,0 +1,33 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/17 + */ +describe("SegmentTest", function () { + + /** + * test_author_windy + */ + it("segment", function () { + var a = BI.Test.createWidget({ + type: "bi.segment", + items: [{ + text: "1", + value: 1 + }, { + text: "2", + value: 2 + }, { + text: "3", + value: 3 + }] + }); + a.setValue(2); + expect(a.getValue()[0]).to.equal(2); + a.setEnable(false); + a.setEnabledValue(3); + a.setValue(3); + expect(a.getValue()[0]).to.equal(3); + a.destroy(); + }); +}); \ No newline at end of file