From 5f4d4df5746dce9e7a04a9b514e5e37d14de9580 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 7 Apr 2020 10:39:44 +0800 Subject: [PATCH] =?UTF-8?q?BI-61182=20test:=20=E4=BF=AE=E5=A4=8D=E6=94=B9?= =?UTF-8?q?=E4=BA=86text=E7=A9=BA=E6=A0=BC=E6=98=BE=E7=A4=BA=E5=90=8E?= =?UTF-8?q?=E7=9A=84=E6=8A=A5=E9=94=99=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/__test__/text.test.js | 2 +- src/case/loader/__test__/loader.lazy.test.js | 49 +++++++++++++++++++ src/case/loader/loader.lazy.js | 3 +- src/core/__test__/alias.test.js | 2 +- src/widget/datetime/__test__/datetime.test.js | 6 +-- .../__test__/dynamicdatetime.test.js | 4 +- .../__test__/timeinterval.test.js | 2 +- 7 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 src/case/loader/__test__/loader.lazy.test.js diff --git a/src/base/single/__test__/text.test.js b/src/base/single/__test__/text.test.js index a2a774d2a3..0aa659ac62 100644 --- a/src/base/single/__test__/text.test.js +++ b/src/base/single/__test__/text.test.js @@ -117,7 +117,7 @@ describe("TextTest", function () { type: "bi.text", text: "我是要标红的 A", }); - expect(text.element.text()).to.equal("我是要标红的 A"); + expect(text.element.text()).to.equal("我是要标红的 A"); text.destroy(); }); diff --git a/src/case/loader/__test__/loader.lazy.test.js b/src/case/loader/__test__/loader.lazy.test.js new file mode 100644 index 0000000000..7f8f8205f6 --- /dev/null +++ b/src/case/loader/__test__/loader.lazy.test.js @@ -0,0 +1,49 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/4/3 + */ + +describe("lazy_loader", function () { + + /** + * test_author_windy + **/ + it("setValue", function () { + var items = BI.map(BI.range(0, 100), function (idx, v) { + return { + type: "bi.single_select_item", + text: v, + value: v + } + }); + var widget = BI.Test.createWidget({ + type: "bi.lazy_loader", + el: { + layouts: [{ + type: "bi.left", + hgap: 5 + }] + } + }); + widget.populate(items); + expect(widget.getAllButtons().length).to.equal(100); + widget.addItems([{ + type: "bi.single_select_item", + text: 102, + value: 102 + }, { + type: "bi.single_select_item", + text: 103, + value: 103 + }]); + expect(widget.getAllLeaves().length).to.equal(102); + widget.setValue(102); + expect(widget.getValue()[0]).to.equal(102); + expect(widget.getSelectedButtons().length).to.equal(1); + widget.setNotSelectedValue(102); + expect(widget.getNotSelectedValue()[0]).to.equal(102); + expect(widget.getNotSelectedButtons().length).to.equal(1); + widget.destroy(); + }); +}); \ No newline at end of file diff --git a/src/case/loader/loader.lazy.js b/src/case/loader/loader.lazy.js index 5096411482..3399400772 100644 --- a/src/case/loader/loader.lazy.js +++ b/src/case/loader/loader.lazy.js @@ -8,7 +8,8 @@ BI.LazyLoader = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.LazyLoader.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-lazy-loader", - el: {} + el: {}, + items: [] }); }, diff --git a/src/core/__test__/alias.test.js b/src/core/__test__/alias.test.js index d2b18b6abc..51297986d8 100644 --- a/src/core/__test__/alias.test.js +++ b/src/core/__test__/alias.test.js @@ -18,7 +18,7 @@ describe("aliasFunctionTest", function () { var targetString = "1 2&"; var encodeString = BI.htmlEncode(targetString); - expect(encodeString).to.equal("<a>1 2&</a>"); + expect(encodeString).to.equal("<a>1 2&</a>"); expect(BI.htmlDecode(encodeString)).to.equal(targetString); }); diff --git a/src/widget/datetime/__test__/datetime.test.js b/src/widget/datetime/__test__/datetime.test.js index 091419604e..ac01dc2c90 100644 --- a/src/widget/datetime/__test__/datetime.test.js +++ b/src/widget/datetime/__test__/datetime.test.js @@ -28,7 +28,7 @@ describe("DateTime", function () { second: 12 } }); - expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); + expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); dateCombo.destroy(); }); @@ -51,7 +51,7 @@ describe("DateTime", function () { BI.nextTick(function () { dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(16)").parent().click(); dateCombo.element.find(".bi-date-time-popup .bi-text:contains(确定)").parent().click(); - expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-16 12:12:12"); + expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-16 12:12:12"); dateCombo.destroy(); done(); }) @@ -77,7 +77,7 @@ describe("DateTime", function () { BI.nextTick(function () { dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(16)").parent().click(); dateCombo.element.find(".bi-date-time-popup .bi-text:contains(取消)").parent().click(); - expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); + expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); dateCombo.destroy(); done(); }) diff --git a/src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js b/src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js index a119186554..acfc0ac520 100644 --- a/src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js +++ b/src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js @@ -32,7 +32,7 @@ describe("DateTimeCombo", function () { } }); BI.nextTick(function () { - expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); + expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); dateCombo.destroy(); done(); }) @@ -318,7 +318,7 @@ describe("DateTimeCombo", function () { input.val("2017-1-1"); BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), null, BI.KeyCode.ENTER, function () { BI.delay(function () { - expect(dateCombo.element.find(".bi-date-time-trigger .bi-text-button").text()).to.equal("2017-01-01 00:00:00"); + expect(dateCombo.element.find(".bi-date-time-trigger .bi-text-button").text()).to.equal("2017-01-01 00:00:00"); dateCombo.destroy(); done(); }, 300); diff --git a/src/widget/timeinterval/__test__/timeinterval.test.js b/src/widget/timeinterval/__test__/timeinterval.test.js index c93714c537..4ab9225a16 100644 --- a/src/widget/timeinterval/__test__/timeinterval.test.js +++ b/src/widget/timeinterval/__test__/timeinterval.test.js @@ -61,7 +61,7 @@ describe("DateInterval", function () { } }, }); - expect(dateInterval.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-01-12 10:10:102019-01-01 00:00:00"); + expect(dateInterval.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-01-12 10:10:102019-01-01 00:00:00"); dateInterval.destroy(); });