From cda779e06d9988160db0f5e112fe7c4689311b27 Mon Sep 17 00:00:00 2001 From: Kobi Date: Tue, 21 Apr 2020 19:44:16 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-3882=20=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../node/__test__/icontexticonnode.test.js | 83 ++++++++++++++++++ .../button/node/__test__/icontextnode.test.js | 83 ++++++++++++++++++ .../button/node/__test__/texticonnode.test.js | 83 ++++++++++++++++++ .../button/node/__test__/textnode.test.js | 85 +++++++++++++++++++ 4 files changed, 334 insertions(+) create mode 100644 src/base/single/button/node/__test__/icontexticonnode.test.js create mode 100644 src/base/single/button/node/__test__/icontextnode.test.js create mode 100644 src/base/single/button/node/__test__/texticonnode.test.js create mode 100644 src/base/single/button/node/__test__/textnode.test.js diff --git a/src/base/single/button/node/__test__/icontexticonnode.test.js b/src/base/single/button/node/__test__/icontexticonnode.test.js new file mode 100644 index 000000000..7166d2f20 --- /dev/null +++ b/src/base/single/button/node/__test__/icontexticonnode.test.js @@ -0,0 +1,83 @@ +/** + * @author Kobi + * @date 2020/4/21 + */ + +describe("IconTextIconNodeTest", function () { + + it("setText", function () { + var iconTextIconNode = BI.Test.createWidget({ + type: "bi.icon_text_icon_node" + }); + iconTextIconNode.setText("AAA"); + expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); + iconTextIconNode.destroy(); + }); + + it("getText", function () { + var iconTextIconNode = BI.Test.createWidget({ + type: "bi.icon_text_icon_node", + text: "AAA", + }); + expect(iconTextIconNode.getText()).to.equal("AAA"); + iconTextIconNode.destroy(); + }); + + it("setValue", function () { + var iconTextIconNode = BI.Test.createWidget({ + type: "bi.icon_text_icon_node" + }); + iconTextIconNode.setValue("AAA"); + expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); + iconTextIconNode.destroy(); + }); + + it("readonly下的setValue", function () { + var iconTextIconNode = BI.Test.createWidget({ + type: "bi.icon_text_icon_node", + value: "AAA", + readonly: true + }); + iconTextIconNode.setValue("BBB"); + expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); + iconTextIconNode.destroy(); + }); + + it("getValue", function () { + var iconTextIconNode = BI.Test.createWidget({ + type: "bi.icon_text_icon_node", + value: "AAA" + }); + expect(iconTextIconNode.getValue()).to.equal("AAA"); + iconTextIconNode.destroy(); + }); + + it("doRedMark和unRedMark", function () { + var iconTextIconNode = BI.Test.createWidget({ + type: "bi.icon_text_icon_node", + text: "要标红的AAA", + }); + iconTextIconNode.doRedMark("AAA"); + expect(iconTextIconNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + iconTextIconNode.unRedMark(); + expect(iconTextIconNode.element.find(".bi-keyword-red-mark").length).to.equal(0); + iconTextIconNode.destroy(); + }); + + it("Click点击触发事件", function (done) { + var iconTextIconNode = BI.Test.createWidget({ + type: "bi.icon_text_icon_node", + text: "AAA", + handler: function () { + this.setText("click"); + } + }); + BI.nextTick(function () { + iconTextIconNode.element.click(); + expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("click"); + iconTextIconNode.destroy(); + done(); + }); + }); + +}); diff --git a/src/base/single/button/node/__test__/icontextnode.test.js b/src/base/single/button/node/__test__/icontextnode.test.js new file mode 100644 index 000000000..b12aab5f3 --- /dev/null +++ b/src/base/single/button/node/__test__/icontextnode.test.js @@ -0,0 +1,83 @@ +/** + * @author Kobi + * @date 2020/4/21 + */ + +describe("IconTextNodeTest", function () { + + it("setText", function () { + var iconTextNode = BI.Test.createWidget({ + type: "bi.icon_text_node" + }); + iconTextNode.setText("AAA"); + expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); + iconTextNode.destroy(); + }); + + it("getText", function () { + var iconTextNode = BI.Test.createWidget({ + type: "bi.icon_text_node", + text: "AAA", + }); + expect(iconTextNode.getText()).to.equal("AAA"); + iconTextNode.destroy(); + }); + + it("setValue", function () { + var iconTextNode = BI.Test.createWidget({ + type: "bi.icon_text_node" + }); + iconTextNode.setValue("AAA"); + expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); + iconTextNode.destroy(); + }); + + it("readonly下的setValue", function () { + var iconTextNode = BI.Test.createWidget({ + type: "bi.icon_text_node", + value: "AAA", + readonly: true + }); + iconTextNode.setValue("BBB"); + expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); + iconTextNode.destroy(); + }); + + it("getValue", function () { + var iconTextNode = BI.Test.createWidget({ + type: "bi.icon_text_node", + value: "AAA" + }); + expect(iconTextNode.getValue()).to.equal("AAA"); + iconTextNode.destroy(); + }); + + it("doRedMark和unRedMark", function () { + var iconTextNode = BI.Test.createWidget({ + type: "bi.icon_text_node", + text: "要标红的AAA", + }); + iconTextNode.doRedMark("AAA"); + expect(iconTextNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + iconTextNode.unRedMark(); + expect(iconTextNode.element.find(".bi-keyword-red-mark").length).to.equal(0); + iconTextNode.destroy(); + }); + + it("Click点击触发事件", function (done) { + var iconTextNode = BI.Test.createWidget({ + type: "bi.icon_text_node", + text: "AAA", + handler: function () { + this.setText("click"); + } + }); + BI.nextTick(function () { + iconTextNode.element.click(); + expect(iconTextNode.element.find(".bi-text").text()).to.equal("click"); + iconTextNode.destroy(); + done(); + }); + }); + +}); diff --git a/src/base/single/button/node/__test__/texticonnode.test.js b/src/base/single/button/node/__test__/texticonnode.test.js new file mode 100644 index 000000000..d6bb5f4d7 --- /dev/null +++ b/src/base/single/button/node/__test__/texticonnode.test.js @@ -0,0 +1,83 @@ +/** + * @author Kobi + * @date 2020/4/21 + */ + +describe("TextIconNodeTest", function () { + + it("setText", function () { + var textIconNode = BI.Test.createWidget({ + type: "bi.text_icon_node" + }); + textIconNode.setText("AAA"); + expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); + textIconNode.destroy(); + }); + + it("getText", function () { + var textIconNode = BI.Test.createWidget({ + type: "bi.text_icon_node", + text: "AAA", + }); + expect(textIconNode.getText()).to.equal("AAA"); + textIconNode.destroy(); + }); + + it("setValue", function () { + var textIconNode = BI.Test.createWidget({ + type: "bi.text_icon_node" + }); + textIconNode.setValue("AAA"); + expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); + textIconNode.destroy(); + }); + + it("readonly下的setValue", function () { + var textIconNode = BI.Test.createWidget({ + type: "bi.text_icon_node", + value: "AAA", + readonly: true + }); + textIconNode.setValue("BBB"); + expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); + textIconNode.destroy(); + }); + + it("getValue", function () { + var textIconNode = BI.Test.createWidget({ + type: "bi.text_icon_node", + value: "AAA" + }); + expect(textIconNode.getValue()).to.equal("AAA"); + textIconNode.destroy(); + }); + + it("doRedMark和unRedMark", function () { + var textIconNode = BI.Test.createWidget({ + type: "bi.text_icon_node", + text: "要标红的AAA", + }); + textIconNode.doRedMark("AAA"); + expect(textIconNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + textIconNode.unRedMark(); + expect(textIconNode.element.find(".bi-keyword-red-mark").length).to.equal(0); + textIconNode.destroy(); + }); + + it("Click点击触发事件", function (done) { + var textIconNode = BI.Test.createWidget({ + type: "bi.text_icon_node", + text: "AAA", + handler: function () { + this.setText("click"); + } + }); + BI.nextTick(function () { + textIconNode.element.click(); + expect(textIconNode.element.find(".bi-text").text()).to.equal("click"); + textIconNode.destroy(); + done(); + }); + }); + +}); diff --git a/src/base/single/button/node/__test__/textnode.test.js b/src/base/single/button/node/__test__/textnode.test.js new file mode 100644 index 000000000..6d885e7c0 --- /dev/null +++ b/src/base/single/button/node/__test__/textnode.test.js @@ -0,0 +1,85 @@ +/** + * @author Kobi + * @date 2020/4/21 + */ + +describe("TextNodeTest", function () { + + it("setText", function () { + var textNode = BI.Test.createWidget({ + type: "bi.text_node" + }); + textNode.setText("AAA"); + expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); + textNode.destroy(); + }); + + it("getText", function () { + var textNode = BI.Test.createWidget({ + type: "bi.text_node", + text: "AAA", + whiteSpace: "normal" + }); + expect(textNode.getText()).to.equal("AAA"); + textNode.destroy(); + }); + + it("setValue", function () { + var textNode = BI.Test.createWidget({ + type: "bi.text_node" + }); + textNode.setValue("AAA"); + expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); + textNode.destroy(); + }); + + it("readonly下的setValue", function () { + var textNode = BI.Test.createWidget({ + type: "bi.text_node", + value: "AAA", + readonly: true + }); + textNode.setValue("BBB"); + expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); + textNode.destroy(); + }); + + it("getValue", function () { + var textNode = BI.Test.createWidget({ + type: "bi.text_node", + value: "AAA" + }); + expect(textNode.getValue()).to.equal("AAA"); + textNode.destroy(); + }); + + it("doRedMark和unRedMark", function () { + var textNode = BI.Test.createWidget({ + type: "bi.text_node", + text: "要标红的AAA", + }); + textNode.doRedMark("AAA"); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + textNode.unRedMark(); + expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); + textNode.destroy(); + }); + + it("Click点击触发事件", function (done) { + var textNode = BI.Test.createWidget({ + type: "bi.text_node", + text: "AAA", + handler: function () { + this.setText("click"); + } + }); + BI.nextTick(function () { + textNode.element.click(); + expect(textNode.element.children(".bi-text").text()).to.equal("click"); + textNode.destroy(); + done(); + }); + }); + + +});