From 7ab2fd15957f83f43c8419990ac62a7d5b8e5eed Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 8 May 2020 18:22:22 +0800 Subject: [PATCH] =?UTF-8?q?BI-61182=20test:=20=E5=8D=95=E6=B5=8B62.21%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- karma.conf.js | 3 +- .../treeitem/__test__/item.treeleaf.test.js | 240 ++++++++++++++++++ .../button/treeitem/item.first.treeleaf.js | 21 +- .../button/treeitem/item.icon.treeleaf.js | 8 - .../button/treeitem/item.last.treeleaf.js | 21 +- src/case/button/treeitem/item.mid.treeleaf.js | 21 +- 6 files changed, 245 insertions(+), 69 deletions(-) create mode 100644 src/case/button/treeitem/__test__/item.treeleaf.test.js diff --git a/karma.conf.js b/karma.conf.js index cdeb3baad..24138a4eb 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -64,7 +64,8 @@ module.exports = function (config) { exclude: [ "src/base/tree/ztree/jquery.ztree.core-3.5.js", - "src/base/tree/ztree/jquery.ztree.excheck-3.5.js" + "src/base/tree/ztree/jquery.ztree.excheck-3.5.js", + "src/base/single/input/file.js", ], diff --git a/src/case/button/treeitem/__test__/item.treeleaf.test.js b/src/case/button/treeitem/__test__/item.treeleaf.test.js new file mode 100644 index 000000000..57b2e66f9 --- /dev/null +++ b/src/case/button/treeitem/__test__/item.treeleaf.test.js @@ -0,0 +1,240 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/5/8 + */ +describe("leafTest", function () { + + /** + * test_author_windy + */ + it("标红与高亮", function () { + var textNode = BI.Test.createWidget({ + type: "bi.first_tree_leaf_item", + id: "1", + pId: "-1", + layer: 0, + height: 24, + text: "ABC", + keyword: "B" + }); + textNode.doRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + textNode.unRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); + textNode.doHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); + textNode.unHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.equal(0); + textNode.destroy(); + }); + + /** + * test_author_windy + */ + it("function", function () { + var textNode = BI.Test.createWidget({ + type: "bi.first_tree_leaf_item", + id: "1", + pId: "-1" + }); + expect(textNode.getId()).to.equal("1"); + expect(textNode.getPId()).to.equal("-1"); + textNode.destroy(); + }); + + + /** + * test_author_windy + */ + it("标红与高亮1", function () { + var textNode = BI.Test.createWidget({ + type: "bi.last_tree_leaf_item", + id: "1", + pId: "-1", + layer: 0, + height: 24, + text: "ABC", + keyword: "B" + }); + textNode.doRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + textNode.unRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); + textNode.doHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); + textNode.unHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.equal(0); + textNode.destroy(); + }); + + /** + * test_author_windy + */ + it("function1", function () { + var textNode = BI.Test.createWidget({ + type: "bi.last_tree_leaf_item", + id: "1", + pId: "-1" + }); + expect(textNode.getId()).to.equal("1"); + expect(textNode.getPId()).to.equal("-1"); + textNode.destroy(); + }); + + + /** + * test_author_windy + */ + it("标红与高亮12", function () { + var textNode = BI.Test.createWidget({ + type: "bi.mid_tree_leaf_item", + id: "1", + pId: "-1", + layer: 0, + height: 24, + text: "ABC", + keyword: "B" + }); + textNode.doRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + textNode.unRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); + textNode.doHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); + textNode.unHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.equal(0); + textNode.destroy(); + }); + + /** + * test_author_windy + */ + it("function12", function () { + var textNode = BI.Test.createWidget({ + type: "bi.mid_tree_leaf_item", + id: "1", + pId: "-1" + }); + expect(textNode.getId()).to.equal("1"); + expect(textNode.getPId()).to.equal("-1"); + textNode.destroy(); + }); + + /** + * test_author_windy + */ + it("标红与高亮123", function () { + var textNode = BI.Test.createWidget({ + type: "bi.icon_tree_leaf_item", + id: "1", + pId: "-1", + layer: 0, + height: 24, + text: "ABC", + keyword: "B" + }); + textNode.doRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + textNode.unRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); + textNode.doHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); + textNode.unHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.equal(0); + textNode.destroy(); + }); + + /** + * test_author_windy + */ + it("function123", function () { + var textNode = BI.Test.createWidget({ + type: "bi.icon_tree_leaf_item", + id: "1", + pId: "-1" + }); + expect(textNode.getId()).to.equal("1"); + expect(textNode.getPId()).to.equal("-1"); + textNode.destroy(); + }); + + + /** + * test_author_windy + */ + it("标红与高亮1234", function () { + var textNode = BI.Test.createWidget({ + type: "bi.multilayer_icon_tree_leaf_item", + id: "1", + pId: "-1", + layer: 0, + height: 24, + text: "ABC", + keyword: "B" + }); + textNode.doRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + textNode.unRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); + textNode.doHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); + textNode.unHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.equal(0); + textNode.destroy(); + }); + + /** + * test_author_windy + */ + it("function1234", function () { + var textNode = BI.Test.createWidget({ + type: "bi.multilayer_icon_tree_leaf_item", + id: "1", + pId: "-1" + }); + expect(textNode.getId()).to.equal("1"); + expect(textNode.getPId()).to.equal("-1"); + textNode.destroy(); + }); + + + /** + * test_author_windy + */ + it("标红与高亮12345", function () { + var textNode = BI.Test.createWidget({ + type: "bi.tree_text_leaf_item", + id: "1", + pId: "-1", + layer: 0, + height: 24, + text: "ABC", + keyword: "B" + }); + textNode.doRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + textNode.unRedMark("C"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); + textNode.doHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); + textNode.unHighLight("C"); + expect(textNode.element.find(".bi-high-light").length).to.equal(0); + textNode.destroy(); + }); + + /** + * test_author_windy + */ + it("function12345", function () { + var textNode = BI.Test.createWidget({ + type: "bi.tree_text_leaf_item", + id: "1", + pId: "-1" + }); + expect(textNode.getId()).to.equal("1"); + expect(textNode.getPId()).to.equal("-1"); + textNode.destroy(); + }); + +}); \ No newline at end of file diff --git a/src/case/button/treeitem/item.first.treeleaf.js b/src/case/button/treeitem/item.first.treeleaf.js index 461548608..afaa2f6fc 100644 --- a/src/case/button/treeitem/item.first.treeleaf.js +++ b/src/case/button/treeitem/item.first.treeleaf.js @@ -13,10 +13,7 @@ BI.FirstTreeLeafItem = BI.inherit(BI.BasicButton, { }, _init: function () { BI.FirstTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.checkbox" - }); + var o = this.options; this.text = BI.createWidget({ type: "bi.label", textAlign: "left", @@ -29,12 +26,6 @@ BI.FirstTreeLeafItem = BI.inherit(BI.BasicButton, { py: o.py, keyword: o.keyword }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.setSelected(self.isSelected()); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { width: 12, @@ -84,16 +75,6 @@ BI.FirstTreeLeafItem = BI.inherit(BI.BasicButton, { getPId: function () { return this.options.pId; - }, - - doClick: function () { - BI.FirstTreeLeafItem.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.FirstTreeLeafItem.superclass.setSelected.apply(this, arguments); - this.checkbox.setSelected(v); } }); diff --git a/src/case/button/treeitem/item.icon.treeleaf.js b/src/case/button/treeitem/item.icon.treeleaf.js index 403ab03d4..f1623d47a 100644 --- a/src/case/button/treeitem/item.icon.treeleaf.js +++ b/src/case/button/treeitem/item.icon.treeleaf.js @@ -75,14 +75,6 @@ BI.IconTreeLeafItem = BI.inherit(BI.BasicButton, { getPId: function () { return this.options.pId; - }, - - doClick: function () { - BI.IconTreeLeafItem.superclass.doClick.apply(this, arguments); - }, - - setSelected: function (v) { - BI.IconTreeLeafItem.superclass.setSelected.apply(this, arguments); } }); diff --git a/src/case/button/treeitem/item.last.treeleaf.js b/src/case/button/treeitem/item.last.treeleaf.js index 135124db6..8b30892a3 100644 --- a/src/case/button/treeitem/item.last.treeleaf.js +++ b/src/case/button/treeitem/item.last.treeleaf.js @@ -13,10 +13,7 @@ BI.LastTreeLeafItem = BI.inherit(BI.BasicButton, { }, _init: function () { BI.LastTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.checkbox" - }); + var o = this.options; this.text = BI.createWidget({ type: "bi.label", textAlign: "left", @@ -29,12 +26,6 @@ BI.LastTreeLeafItem = BI.inherit(BI.BasicButton, { py: o.py, keyword: o.keyword }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.setSelected(self.isSelected()); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { width: 12, @@ -84,16 +75,6 @@ BI.LastTreeLeafItem = BI.inherit(BI.BasicButton, { getPId: function () { return this.options.pId; - }, - - doClick: function () { - BI.LastTreeLeafItem.superclass.doClick.apply(this, arguments); - // this.checkbox.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.LastTreeLeafItem.superclass.setSelected.apply(this, arguments); - // this.checkbox.setSelected(v); } }); diff --git a/src/case/button/treeitem/item.mid.treeleaf.js b/src/case/button/treeitem/item.mid.treeleaf.js index 77a4126e8..a3a7a6c93 100644 --- a/src/case/button/treeitem/item.mid.treeleaf.js +++ b/src/case/button/treeitem/item.mid.treeleaf.js @@ -13,10 +13,7 @@ BI.MidTreeLeafItem = BI.inherit(BI.BasicButton, { }, _init: function () { BI.MidTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.checkbox" - }); + var o = this.options; this.text = BI.createWidget({ type: "bi.label", textAlign: "left", @@ -29,12 +26,6 @@ BI.MidTreeLeafItem = BI.inherit(BI.BasicButton, { py: o.py, keyword: o.keyword }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.setSelected(self.isSelected()); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { width: 12, @@ -84,16 +75,6 @@ BI.MidTreeLeafItem = BI.inherit(BI.BasicButton, { getPId: function () { return this.options.pId; - }, - - doClick: function () { - BI.MidTreeLeafItem.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.MidTreeLeafItem.superclass.setSelected.apply(this, arguments); - this.checkbox.setSelected(v); } });