diff --git a/karma.conf.js b/karma.conf.js index 209837431f..c57e74c93c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -26,6 +26,24 @@ module.exports = function (config) { "src/core/plugin.js", "src/core/**/*.js", "src/data/**/*.js", + "src/data/**/*.js", + "src/data/**/*.js", + "src/third/**/*.js", + "src/base/pane.js", + "src/base/single/single.js", + "src/base/single/text.js", + "src/base/single/button/button.basic.js", + "src/base/single/button/button.node.js", + "src/base/single/tip/tip.js", + "src/base/combination/group.button.js", + "src/base/combination/tree.button.js", + "src/base/tree/ztree/treeview.js", + "src/base/tree/ztree/asynctree.js", + "src/base/tree/ztree/parttree.js", + "src/base/tree/ztree/list/listtreeview.js", + "src/base/tree/ztree/list/listasynctree.js", + "src/base/tree/ztree/list/listparttree.js", + "src/base/**/*.js", "src/**/*.test.js", "test/**/*.js" ], @@ -36,7 +54,8 @@ module.exports = function (config) { preprocessors: { "src/core/alias.js": "coverage", "src/core/base.js": "coverage", - "src/core/func/date.js": "coverage" + "src/core/func/date.js": "coverage", + "src/base/**/*.js": "coverage" }, @@ -45,13 +64,18 @@ module.exports = function (config) { // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ["progress", "coverage"], + browserDisconnectTolerance: 3, + browserDisconnectTimeout : 300000, + browserNoActivityTimeout : 300000, + coverageReporter: { // specify a common output directory dir: "coverage/", reporters: [ // reporters not supporting the `file` property { type: "html", subdir: "report-html" }, - { type: "json-summary", subdir: "report-json-summary" } + { type: "json-summary", subdir: "report-json-summary" }, + { type: "cobertura", subdir: "report-cobertura"} ] }, diff --git a/test/utils.js b/test/utils.js new file mode 100644 index 0000000000..a377cb3a3d --- /dev/null +++ b/test/utils.js @@ -0,0 +1,12 @@ +!(function () { + BI.Test = {}; + _.extend(BI.Test, { + createWidget: function (widgetJson) { + var widget = BI.createWidget(widgetJson); + widget._isRoot = true; + widget._mount(); + widget.element.appendTo("body"); + return widget; + } + }) +})(); \ No newline at end of file diff --git a/test/widget/button.test.js b/test/widget/button.test.js new file mode 100644 index 0000000000..34fb15ca6d --- /dev/null +++ b/test/widget/button.test.js @@ -0,0 +1,24 @@ +/** + * Created by windy on 2018/01/23. + */ +describe("ButtonTest", function () { + + /** + * test_author_windy + */ + it("EventClickTest", function (done) { + var button = BI.Test.createWidget({ + type: "bi.button", + text: "CCC", + handler: function () { + this.setText("click"); + } + }); + BI.nextTick(function () { + button.element.click(); + expect(button.element[0].querySelector(".bi-text").textContent).to.equal("click"); + done(); + }); + + }); +}); diff --git a/test/widget/text.test.js b/test/widget/text.test.js new file mode 100644 index 0000000000..1f8e8b49de --- /dev/null +++ b/test/widget/text.test.js @@ -0,0 +1,27 @@ +/** + * Created by windy on 2018/01/23. + */ +describe("TextTest", function () { + + /** + * test_author_windy + */ + it("setText", function () { + var text = BI.Test.createWidget({ + type: "bi.text" + }); + text.setText("AAA"); + expect(text.element[0].textContent).to.equal("AAA"); + }); + + /** + * test_author_windy + */ + it("setStyle", function () { + var text = BI.Test.createWidget({ + type: "bi.text" + }); + text.setStyle({"color": "red"}); + expect(text.element[0].style.color).to.equal("red"); + }); +});