diff --git a/.eslintrc b/.eslintrc index 12defcd8a..41426aa36 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,7 +2,8 @@ "env": { "browser": true, "node": true, - "es6": true + "es6": true, + "jest": true }, "globals": { "window": true, diff --git a/src/base/collection/__test__/collection.test.js b/src/base/collection/__test__/collection.test.js index 381735ac3..6ce44fc22 100644 --- a/src/base/collection/__test__/collection.test.js +++ b/src/base/collection/__test__/collection.test.js @@ -5,7 +5,6 @@ */ describe("CollectionTest", function () { - /** * test_author_windy */ @@ -35,4 +34,4 @@ describe("CollectionTest", function () { // TODO 列表展示类控件不知道该测什么,先标记一下 grid.destroy(); }); -}); \ No newline at end of file +}); diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index 8605e70c5..d28adebf1 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -58,7 +58,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { if (o.overflowY === false) { scrollable = false; } else { - scrollable = "y" + scrollable = "y"; } } else { if (o.overflowY === false) { @@ -84,7 +84,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { // mounted之后绑定事件 mounted: function () { - var o = this.options; + var o = this.options; if (o.scrollLeft !== 0 || o.scrollTop !== 0) { this.element.scrollTop(o.scrollTop); this.element.scrollLeft(o.scrollLeft); @@ -101,10 +101,10 @@ BI.CollectionView = BI.inherit(BI.Widget, { for (var index = 0, len = o.items.length; index < len; index++) { var cellMetadatum = o.cellSizeAndPositionGetter(index); - if (cellMetadatum.height == null || isNaN(cellMetadatum.height) || - cellMetadatum.width == null || isNaN(cellMetadatum.width) || - cellMetadatum.x == null || isNaN(cellMetadatum.x) || - cellMetadatum.y == null || isNaN(cellMetadatum.y)) { + if (cellMetadatum.height === null || isNaN(cellMetadatum.height) || + cellMetadatum.width === null || isNaN(cellMetadatum.width) || + cellMetadatum.x === null || isNaN(cellMetadatum.x) || + cellMetadatum.y === null || isNaN(cellMetadatum.y)) { throw Error(); } @@ -124,16 +124,18 @@ BI.CollectionView = BI.inherit(BI.Widget, { _cellRenderers: function (height, width, x, y) { this._lastRenderedCellIndices = this._sectionManager.getCellIndices(height, width, x, y); + return this._cellGroupRenderer(); }, _cellGroupRenderer: function () { - var self = this, o = this.options; + var self = this; var rendered = []; BI.each(this._lastRenderedCellIndices, function (i, index) { var cellMetadata = self._sectionManager.getCellMetadata(index); rendered.push(cellMetadata); }); + return rendered; }, @@ -167,16 +169,16 @@ BI.CollectionView = BI.inherit(BI.Widget, { var topMap = BI.invert(tops); // 存储上下左右四个边界 var leftBorder = {}, rightBorder = {}, topBorder = {}, bottomBorder = {}; - var assertMinBorder = function (border, offset) { - if (border[offset] == null) { + function assertMinBorder(border, offset) { + if (border[offset] === null) { border[offset] = Number.MAX_VALUE; } - }; - var assertMaxBorder = function (border, offset) { - if (border[offset] == null) { + } + function assertMaxBorder(border, offset) { + if (border[offset] === null) { border[offset] = 0; } - }; + } for (var i = 0, len = childrenToDisplay.length; i < len; i++) { var datum = childrenToDisplay[i]; var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1]; @@ -194,7 +196,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { this.renderedCells[index].el.element.css("left", datum.x / BI.pixRatio + BI.pixUnit); // } // if (this.renderedCells[index]._top !== datum.y) { - this.renderedCells[index].el.element.css("top", datum.y / BI.pixRatio + BI.pixUnit); + this.renderedCells[index].el.element.css("top", datum.y / BI.pixRatio + BI.pixUnit); // } renderedCells.push(child = this.renderedCells[index]); } else { @@ -213,7 +215,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { left: datum.x, top: datum.y, _left: datum.x, - _top: datum.y, + _top: datum.y // _width: datum.width, // _height: datum.height }); @@ -280,7 +282,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { var minY = BI.max(topBorder); var maxY = BI.min(bottomBorder); - this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; + this.renderRange = { minX: minX, minY: minY, maxX: maxX, maxY: maxY }; } }, @@ -308,6 +310,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { this.element.scrollTop(o.scrollTop); this.element.scrollLeft(o.scrollLeft); } catch (e) { + throw new Error("Failed in some way", { cause: e }); } this._calculateChildrenToRender(); }, @@ -339,7 +342,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { if (this.options.overflowX !== !!b) { this.options.overflowX = !!b; BI.nextTick(function () { - self.element.css({overflowX: b ? "auto" : "hidden"}); + self.element.css({ overflowX: b ? "auto" : "hidden" }); }); } }, @@ -349,7 +352,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { if (this.options.overflowY !== !!b) { this.options.overflowY = !!b; BI.nextTick(function () { - self.element.css({overflowY: b ? "auto" : "hidden"}); + self.element.css({ overflowY: b ? "auto" : "hidden" }); }); } }, diff --git a/src/base/foundation/__test__/message.test.js b/src/base/foundation/__test__/message.test.js index 7097c50ff..5e4890147 100644 --- a/src/base/foundation/__test__/message.test.js +++ b/src/base/foundation/__test__/message.test.js @@ -4,7 +4,6 @@ * Created by windy on 2020/3/9 */ describe("MessageTest", function () { - /** * test_author_windy */ @@ -44,4 +43,3 @@ describe("MessageTest", function () { expect(body.find(".bi-toast").length).to.equal(1); }); }); - diff --git a/src/base/tree/customtree.js b/src/base/tree/customtree.js index a72edba2a..fc7ce4736 100644 --- a/src/base/tree/customtree.js +++ b/src/base/tree/customtree.js @@ -47,7 +47,7 @@ BI.CustomTree = BI.inherit(BI.Widget, { el: { value: node.value }, - popup: {type: "bi.custom_tree"} + popup: { type: "bi.custom_tree" } }, BI.deepClone(o.expander), { id: node.id, pId: node.pId @@ -68,6 +68,7 @@ BI.CustomTree = BI.inherit(BI.Widget, { } var args = Array.prototype.slice.call(arguments, 0); args[0].node = node; + return o.itemsCreator.apply(self, args); }; BI.isNull(item.popup.el) && (item.popup.el = BI.deepClone(o.el)); @@ -76,6 +77,7 @@ BI.CustomTree = BI.inherit(BI.Widget, { items.push(node); } }); + return items; }, @@ -145,4 +147,4 @@ BI.CustomTree = BI.inherit(BI.Widget, { }); BI.CustomTree.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.custom_tree", BI.CustomTree); \ No newline at end of file +BI.shortcut("bi.custom_tree", BI.CustomTree);