From 24fc6f5dd5a7df56405cf2b4a5b706a89fc533b8 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 9 Apr 2020 16:57:59 +0800 Subject: [PATCH] =?UTF-8?q?BI-63029=20fix:=20=E5=A4=A7=E6=95=B4=E6=95=B0?= =?UTF-8?q?=E8=BE=93=E5=85=A5pager=E4=BC=9A=E5=9B=9E=E5=88=B0=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E9=A1=B5=20&&=20=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/pager/pager.js | 4 +- src/case/pager/pager.js | 4 +- src/core/__test__/base.test.js | 131 +++++++++++++++++++++++++++++++++ src/core/base.js | 1 + 4 files changed, 136 insertions(+), 4 deletions(-) diff --git a/src/base/pager/pager.js b/src/base/pager/pager.js index 35a32739b..03d9d7b8f 100644 --- a/src/base/pager/pager.js +++ b/src/base/pager/pager.js @@ -168,7 +168,7 @@ BI.Pager = BI.inherit(BI.Widget, { return BI.extend({ disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow) }, next); - + }())); } @@ -244,7 +244,7 @@ BI.Pager = BI.inherit(BI.Widget, { setValue: function (v) { var o = this.options; - v = v | 0; + v = v || 0; v = v < 1 ? 1 : v; if (o.pages === false) { var lastPage = BI.result(o, "lastPage"), firstPage = 1; diff --git a/src/case/pager/pager.js b/src/case/pager/pager.js index ed9b8dec7..cc057fd69 100644 --- a/src/case/pager/pager.js +++ b/src/case/pager/pager.js @@ -168,7 +168,7 @@ BI.DetailPager = BI.inherit(BI.Widget, { return BI.extend({ disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow) }, next); - + }())); } @@ -244,7 +244,7 @@ BI.DetailPager = BI.inherit(BI.Widget, { setValue: function (v) { var o = this.options; - v = v | 0; + v = v || 0; v = v < 1 ? 1 : v; if (o.pages === false) { var lastPage = BI.result(o, "lastPage"), firstPage = 1; diff --git a/src/core/__test__/base.test.js b/src/core/__test__/base.test.js index 1b3ab1ebd..950a32e9b 100644 --- a/src/core/__test__/base.test.js +++ b/src/core/__test__/base.test.js @@ -129,4 +129,135 @@ describe("baseFunctionTest", function () { c: 3 }); }); + + /** + * test_author_windy + */ + it("assert-warning", function () { + expect(BI.assert("a", "a")).to.equal(true); + expect(BI.assert("a", function (v) { + return v === "a"; + })).to.equal(true); + var test = ""; + try { + BI.assert("a", function (v) { + return v === "c"; + }); + } catch (e) { + test = true; + } + expect(test).to.equal(true); + }); + + /** + * test_author_windy + */ + it("packageItems", function () { + expect(BI.packageItems([{ + type: "a", + text: "b" + }, { + type: "b", + text: "c" + }], [{ + type: "bi.vertical" + }, { + type: "bi.center_adapt" + }])).to.deep.equal([{ + type: "bi.vertical", + items: [{ + el: { + type: "bi.center_adapt", + items: [{ + el: { + type: "a", + text: "b" + } + }] + } + }] + }, { + type: "bi.vertical", + items: [{ + el: { + type: "bi.center_adapt", + items: [{ + el: { + type: "b", + text: "c" + } + }] + } + }] + }]); + }); + + /** + * test_author_windy + */ + it("inverse", function () { + expect(BI.inverse(7, 1)).to.equal(6); + }); + + /** + * test_author_windy + */ + it("key", function () { + var a = { + c: 1, + d: 2 + }; + expect(BI.firstKey(a)).to.equal("c"); + expect(BI.lastKey(a)).to.equal("d"); + expect(BI.firstObject(a)).to.equal(1); + expect(BI.lastObject(a)).to.equal(2); + }); + + + /** + * test_author_windy + */ + it("back", function () { + var a = [{ + c: 1, + d: 2 + }, { + c: 3, + d: 4 + }, { + c: 5, + d: 6 + }]; + var c = []; + BI.backEach(a, function (idx, v) { + c.push(v.d); + }); + expect(c).to.deep.equal([6, 4, 2]); + expect(BI.backEvery(a, function (idx, v) { + return v.c = 1; + })).to.equal(true); + expect(BI.backFindKey({ + c: 5, + d: 6 + }, function (value, key) { + return key === "c"; + })).to.equal("c"); + expect(BI.backFind({ + c: 5, + d: 6 + }, function (v, key) { + return v === 5; + })).to.deep.equal(5); + }); + + + /** + * test_author_windy + */ + it("abc", function () { + expect(BI.abc2Int("B")).to.equal(2); + expect(BI.int2Abc(2)).to.equal("B"); + }); + + }); diff --git a/src/core/base.js b/src/core/base.js index f4a58bfd4..f2b9483a1 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -52,6 +52,7 @@ if (!_global.BI) { if (!this.deepContains(is, v)) { throw new Error(v + " error"); } + return true; }, warn: function (message) {