diff --git a/src/case/button/node/__test__/node.arrow.test.js b/src/case/button/node/__test__/node.arrow.test.js new file mode 100644 index 000000000..4b2a08ef5 --- /dev/null +++ b/src/case/button/node/__test__/node.arrow.test.js @@ -0,0 +1,79 @@ +/** + * @author Kobi + * @date 2020/5/12 + */ + +describe("test node.arrow", function () { + + /** + * test_author_kobi + **/ + it("doRedMark 和 unRedMark", function () { + var widget = BI.Test.createWidget({ + type: "bi.arrow_group_node", + text: "要标红的AAA", + }); + widget.doRedMark("AAA"); + expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + widget.unRedMark(); + expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); + widget.destroy(); + }); + + /** + * test_author_kobi + **/ + it("doClick", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.arrow_group_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.element.click(); + expect(widget.element.find(".expander-down-font").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".expander-right-font").length).to.not.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); + + /** + * test_author_kobi + **/ + it("点击图标", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.arrow_group_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".expander-down-font").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".expander-right-font").length).to.not.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); + + /** + * test_author_kobi + **/ + it("setText", function () { + var widget = BI.Test.createWidget({ + type: "bi.arrow_group_node", + text: "AAA", + }); + widget.setText("BBB"); + expect(widget.element.find(".bi-text").text()).to.equal("BBB"); + widget.destroy(); + }); +}); diff --git a/src/case/button/node/__test__/node.first.plus.test.js b/src/case/button/node/__test__/node.first.plus.test.js new file mode 100644 index 000000000..28912a1ca --- /dev/null +++ b/src/case/button/node/__test__/node.first.plus.test.js @@ -0,0 +1,66 @@ +/** + * @author Kobi + * @date 2020/5/12 + */ + +describe("test node.first.plus", function () { + + /** + * test_author_kobi + **/ + it("doRedMark 和 unRedMark", function () { + var widget = BI.Test.createWidget({ + type: "bi.first_plus_group_node", + text: "要标红的AAA", + }); + widget.doRedMark("AAA"); + expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + widget.unRedMark(); + expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); + widget.destroy(); + }); + + /** + * test_author_kobi + **/ + it("doClick", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.first_plus_group_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.element.click(); + expect(widget.element.find(".tree-expand-icon-type2").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.element.click(); + expect(widget.element.find(".tree-expand-icon-type2").length).to.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); + + /** + * test_author_kobi + **/ + it("点击图标", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.first_plus_group_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".tree-expand-icon-type2").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".tree-expand-icon-type2").length).to.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); +}); diff --git a/src/case/button/node/__test__/node.icon.arrow.test.js b/src/case/button/node/__test__/node.icon.arrow.test.js new file mode 100644 index 000000000..d5bd74dbb --- /dev/null +++ b/src/case/button/node/__test__/node.icon.arrow.test.js @@ -0,0 +1,66 @@ +/** + * @author Kobi + * @date 2020/5/12 + */ + +describe("test node.icon.arrow", function () { + + /** + * test_author_kobi + **/ + it("doRedMark 和 unRedMark", function () { + var widget = BI.Test.createWidget({ + type: "bi.icon_arrow_node", + text: "要标红的AAA", + }); + widget.doRedMark("AAA"); + expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + widget.unRedMark(); + expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); + widget.destroy(); + }); + + /** + * test_author_kobi + **/ + it("doClick", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.icon_arrow_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.element.click(); + expect(widget.element.find(".expander-down-font").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".expander-right-font").length).to.not.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); + + /** + * test_author_kobi + **/ + it("点击图标", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.icon_arrow_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".expander-down-font").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".expander-right-font").length).to.not.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); +}); diff --git a/src/case/button/node/__test__/node.last.plus.test.js b/src/case/button/node/__test__/node.last.plus.test.js new file mode 100644 index 000000000..53fab71d9 --- /dev/null +++ b/src/case/button/node/__test__/node.last.plus.test.js @@ -0,0 +1,66 @@ +/** + * @author Kobi + * @date 2020/5/12 + */ + +describe("test node.last.plus", function () { + + /** + * test_author_kobi + **/ + it("doRedMark 和 unRedMark", function () { + var widget = BI.Test.createWidget({ + type: "bi.last_plus_group_node", + text: "要标红的AAA", + }); + widget.doRedMark("AAA"); + expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + widget.unRedMark(); + expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); + widget.destroy(); + }); + + /** + * test_author_kobi + **/ + it("doClick", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.last_plus_group_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.element.click(); + expect(widget.element.find(".tree-expand-icon-type4").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.element.click(); + expect(widget.element.find(".tree-expand-icon-type4").length).to.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); + + /** + * test_author_kobi + **/ + it("点击图标", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.last_plus_group_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".tree-expand-icon-type4").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".tree-expand-icon-type4").length).to.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); +}); diff --git a/src/case/button/node/__test__/node.mid.plus.test.js b/src/case/button/node/__test__/node.mid.plus.test.js new file mode 100644 index 000000000..d5c899c28 --- /dev/null +++ b/src/case/button/node/__test__/node.mid.plus.test.js @@ -0,0 +1,66 @@ +/** + * @author Kobi + * @date 2020/5/12 + */ + +describe("test node.mid.plus", function () { + + /** + * test_author_kobi + **/ + it("doRedMark 和 unRedMark", function () { + var widget = BI.Test.createWidget({ + type: "bi.mid_plus_group_node", + text: "要标红的AAA", + }); + widget.doRedMark("AAA"); + expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + widget.unRedMark(); + expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); + widget.destroy(); + }); + + /** + * test_author_kobi + **/ + it("doClick", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.mid_plus_group_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.element.click(); + expect(widget.element.find(".tree-expand-icon-type3").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.element.click(); + expect(widget.element.find(".tree-expand-icon-type3").length).to.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); + + /** + * test_author_kobi + **/ + it("点击图标", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.mid_plus_group_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".tree-expand-icon-type3").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".tree-expand-icon-type3").length).to.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); +}); diff --git a/src/case/button/node/__test__/node.multilayer.icon.arrow.test.js b/src/case/button/node/__test__/node.multilayer.icon.arrow.test.js new file mode 100644 index 000000000..c060e5499 --- /dev/null +++ b/src/case/button/node/__test__/node.multilayer.icon.arrow.test.js @@ -0,0 +1,73 @@ +/** + * @author Kobi + * @date 2020/5/12 + */ + +describe("test node.multilayer.icon.arrow", function () { + + /** + * test_author_kobi + **/ + it("doRedMark 和 unRedMark", function () { + var widget = BI.Test.createWidget({ + type: "bi.multilayer_icon_arrow_node", + text: "要标红的AAA", + layer: 3, + }); + expect(widget.isOnce()).to.equal(true); + widget.doRedMark("AAA"); + expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + widget.unRedMark(); + expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); + widget.destroy(); + }); + + /** + * test_author_kobi + **/ + it("isSelected 和 setSelected", function () { + var widget = BI.Test.createWidget({ + type: "bi.multilayer_icon_arrow_node", + text: "AAA", + layer: 3, + }); + widget.setSelected(true); + expect(widget.element.find(".active").length).to.not.equal(0); + expect(widget.isSelected()).to.equal(true); + widget.destroy(); + }); + + /** + * test_author_kobi + **/ + it("doClick", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.multilayer_icon_arrow_node", + text: "AAA", + layer: 3, + }); + BI.nextTick(function () { + widget.element.click(); + expect(widget.isSelected()).to.equal(true); + widget.destroy(); + done(); + }); + }); + + /** + * test_author_kobi + **/ + it("点击图标", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.multilayer_icon_arrow_node", + text: "AAA", + layer: 3, + }); + BI.nextTick(function () { + widget.node.element.click(); + expect(widget.element.find(".expander-down-font").length).to.not.equal(0); + widget.destroy(); + done(); + }); + }); +}); diff --git a/src/case/button/node/__test__/node.plus.test.js b/src/case/button/node/__test__/node.plus.test.js new file mode 100644 index 000000000..aebcf46bf --- /dev/null +++ b/src/case/button/node/__test__/node.plus.test.js @@ -0,0 +1,66 @@ +/** + * @author Kobi + * @date 2020/5/12 + */ + +describe("test node.plus", function () { + + /** + * test_author_kobi + **/ + it("doRedMark 和 unRedMark", function () { + var widget = BI.Test.createWidget({ + type: "bi.plus_group_node", + text: "要标红的AAA", + }); + widget.doRedMark("AAA"); + expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); + widget.unRedMark(); + expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); + widget.destroy(); + }); + + /** + * test_author_kobi + **/ + it("doClick", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.plus_group_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.element.click(); + expect(widget.element.find(".tree-expand-icon-type1").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.element.click(); + expect(widget.element.find(".tree-expand-icon-type1").length).to.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); + + /** + * test_author_kobi + **/ + it("点击图标", function (done) { + var widget = BI.Test.createWidget({ + type: "bi.plus_group_node", + text: "AAA", + }); + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".tree-expand-icon-type1").length).to.not.equal(0); + BI.delay(function () { + BI.nextTick(function () { + widget.checkbox.element.click(); + expect(widget.element.find(".tree-expand-icon-type1").length).to.equal(0); + widget.destroy(); + done(); + }); + }, 300); + }); + }); +}); diff --git a/src/core/__test__/alias.test.js b/src/core/__test__/alias.test.js index 51297986d..e97395a42 100644 --- a/src/core/__test__/alias.test.js +++ b/src/core/__test__/alias.test.js @@ -31,4 +31,105 @@ describe("aliasFunctionTest", function () { expect(encodeString).to.equal("tableName120"); expect(BI.decodeURIComponent(encodeString)).to.equal(targetString); }); + + /** + * test_author_kobi + **/ + it("cjkEncode 和 cjkDecode ", function () { + expect(BI.cjkEncode("测试")).to.eql("[6d4b][8bd5]"); + expect(BI.cjkEncode(123)).to.eql(123); + expect(BI.cjkDecode("[6d4b][8bd5]")).to.eql("测试"); + expect(BI.cjkDecode("6d4b 8bd5")).to.eql("6d4b 8bd5"); + expect(BI.cjkDecode(null)).to.eql(""); + }); + + /** + * test_author_kobi + **/ + it("jsonEncode 和 jsonDecode", function () { + var jsonString = '{"a":1,"b":"测\\"试","c":[5,6],"d":null,"e":false}'; + var obj = { + a: 1, + b: '测"试', + c: [5, 6], + d: null, + e: false, + }; + expect(BI.jsonEncode(obj)).to.eql(jsonString); + expect(BI.jsonDecode(jsonString)).to.eql(obj); + + expect(BI.jsonEncode({ a: function(){return 1} })).to.eql('{"a":function(){return 1}}'); + expect(BI.jsonDecode("{__time__:878313600000}")).to.eql(new Date(878313600000)); + }); + + /** + * test_author_kobi + **/ + it("getEncodeURL", function () { + expect(BI.getEncodeURL("design/{tableName}/{fieldName}",{tableName: "A", fieldName: "a"})).to.eql("design/A/a"); + }); + + /** + * test_author_kobi + **/ + it("contentFormat", function () { + expect(BI.contentFormat("", "DTyyyy-MM-dd")).to.eql(""); + expect(BI.contentFormat(878313600000, "")).to.eql("878313600000"); + expect(BI.contentFormat("test", "T")).to.eql("test"); + expect(BI.contentFormat(878313600000, "E")).to.eql("9E11"); + expect(BI.contentFormat(1000.23456789, "0,000.####")).to.eql("1,000.2346"); + expect(BI.contentFormat(879051600000, "DTyyyy-MM-dd")).to.eql("1997-11-09"); + expect(BI.contentFormat(879051600000, "DTyyyy-MM-dd HH:mm:ss a z")).to.eql("1997-11-09 13:00:00 pm "); + expect(BI.contentFormat(879051600000, "DTyyyy-MM-dd hh:mm:ss a z")).to.eql("1997-11-09 01:00:00 pm "); + expect(BI.contentFormat(879051600000, "DTyyy-M-d H:m:s a z")).to.eql("97-11-9 13:0:0 pm "); + expect(BI.contentFormat(879048000000, "DTyyy-M-d h:m:s a z")).to.eql("97-11-9 12:0:0 pm "); + }); + + /** + * test_author_kobi + **/ + it("parseFmt", function () { + expect(BI.parseFmt("yyyy-MM-dd HH:mm:ss")).to.eql("%Y-%X-%d %H:%M:%S"); + expect(BI.parseFmt("yyyy-MM-d hh:mm:ss")).to.eql("%Y-%X-%e %I:%M:%S"); + expect(BI.parseFmt("")).to.eql(""); + }); + + /** + * test_author_kobi + **/ + it("str2Date", function () { + expect(BI.str2Date('2013-12-12', 'yyyy-MM-dd')).to.eql(new Date(2013, 11, 12)); + expect(BI.str2Date('2013-12-12', 123)).to.eql(null); + }); + + /** + * test_author_kobi + **/ + it("object2Number", function () { + expect(BI.object2Number(null)).to.eql(0); + expect(BI.object2Number(123)).to.eql(123); + expect(BI.object2Number("1.23")).to.eql(1.23); + expect(BI.object2Number({ a: 2 })).to.eql(NaN); + }); + + /** + * test_author_kobi + **/ + it("object2Date", function () { + expect(BI.object2Date(null)).to.eql(new Date()); + expect(BI.object2Date(new Date(1997, 10, 9))).to.eql(new Date(1997, 10, 9)); + expect(BI.object2Date(879051600000)).to.eql(new Date(879051600000)); + expect(BI.object2Time("1997-11-09")).to.eql(new Date(1997, 10, 9)); + expect(BI.object2Date({ a: 2 })).to.eql(new Date()); + }); + + /** + * test_author_kobi + **/ + it("object2Time", function () { + expect(BI.object2Time(null)).to.eql(new Date()); + expect(BI.object2Time(new Date(1997, 11, 9))).to.eql(new Date(1997, 11, 9)); + expect(BI.object2Time("1997-11-09 13:00:00")).to.eql(new Date(1997, 10, 9, 13, 0, 0)); + expect(BI.object2Time("13:00:00")).to.eql(new Date(1970, 0, 1, 13, 0, 0)); + }); }); diff --git a/src/core/__test__/base.test.js b/src/core/__test__/base.test.js index df933bae7..ddc3fd130 100644 --- a/src/core/__test__/base.test.js +++ b/src/core/__test__/base.test.js @@ -285,7 +285,7 @@ describe("baseFunctionTest", function () { it("number", function () { expect(BI.parseSafeInt(9007199254740992)).to.equal(9007199254740991); expect(BI.isNegativeInteger(-3)).to.equal(true); - expect(BI.isFloat(1.2)).to.equal(false); + expect(BI.isFloat(1.2)).to.equal(true); expect(BI.isOdd(1)).to.equal(true); expect(BI.isOdd("a")).to.equal(false); expect(BI.isEven("a")).to.equal(false); @@ -304,7 +304,132 @@ describe("baseFunctionTest", function () { expect(BI.camelize("background-color")).to.equal("backgroundColor"); expect(BI.escape("'\\")).to.equal("\\'\\\\"); expect(BI.leftPad("123", 5, "0")).to.equal("00123"); - var cls = 'my-class', text = 'Some text'; - expect(BI.format('