diff --git a/karma.conf.js b/karma.conf.js index 8c1c2e24da..ae5a5a85f1 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -17,6 +17,7 @@ module.exports = function (config) { "src/css/core/**/*.css", "src/css/theme/**/*.css", "src/css/base/**/*.css", + "src/css/widget/**/*.css", "src/core/foundation.js", "src/core/lodash.js", "src/core/base.js", @@ -47,6 +48,9 @@ module.exports = function (config) { "src/base/tree/ztree/list/listasynctree.js", "src/base/tree/ztree/list/listparttree.js", "src/base/**/*.js", + "src/case/**/*.js", + "src/widget/**/*.js", + "src/component/**/*.js", "src/**/*.test.js", "test/**/*.js" ], @@ -58,7 +62,10 @@ module.exports = function (config) { "src/core/alias.js": "coverage", "src/core/base.js": "coverage", "src/core/func/date.js": "coverage", - "src/base/**/!(*.test).js": "coverage" + "src/base/**/!(*.test).js": "coverage", + "src/case/**/!(*.test).js": "coverage", + "src/widget/**/!(*.test).js": "coverage", + "src/component/**/!(*.test).js": "coverage" }, diff --git a/src/base/__test__/a.test.js b/src/base/__test__/a.test.js new file mode 100644 index 0000000000..9e5b508ad6 --- /dev/null +++ b/src/base/__test__/a.test.js @@ -0,0 +1,30 @@ +/** + * Created by windy on 2018/01/23. + */ +describe("ALinkTest", function () { + + /** + * test_author_windy + */ + it("A初始化测试", function () { + var a = BI.Test.createWidget({ + type: "bi.a", + text: "CCC" + }); + expect(a.element.is('a')).to.equal(true); + }); + + /** + * test_author_windy + */ + it("A的el测试", function () { + var a = BI.Test.createWidget({ + type: "bi.a", + text: "DDD", + el: { + type: "bi.label" + } + }); + expect(a.element.is('a') && a.element.hasClass("bi-label")).to.equal(true); + }); +}); diff --git a/src/base/__test__/text.test.js b/src/base/__test__/text.test.js index 332caa8ab1..a2a774d2a3 100644 --- a/src/base/__test__/text.test.js +++ b/src/base/__test__/text.test.js @@ -81,4 +81,77 @@ describe("TextTest", function () { expect(text.element.children(".bi-keyword-red-mark").length).to.equal(0); text.destroy(); }); + + /** + * test_author_windy + */ + it("setValue", function () { + var text = BI.Test.createWidget({ + type: "bi.text", + value: "AAA", + }); + text.setValue("value"); + expect(text.element.text()).to.equal("value"); + text.destroy(); + }); + + /** + * test_author_windy + */ + it("gap测试", function () { + var text = BI.Test.createWidget({ + type: "bi.text", + text: "我是要标红的A", + vgap: 10, + hgap: 10 + }); + expect(text.element.css("padding")).to.equal("10px"); + text.destroy(); + }); + + /** + * test_author_windy + */ + it("空格测试", function () { + var text = BI.Test.createWidget({ + type: "bi.text", + text: "我是要标红的 A", + }); + expect(text.element.text()).to.equal("我是要标红的 A"); + text.destroy(); + }); + + /** + * test_author_windy + */ + it("lineHeight和height", function () { + var text = BI.Test.createWidget({ + type: "bi.text", + text: "我是A", + lineHeight: 12, + height: 24 + }); + expect(text.element.css("height")).to.equal("24px"); + expect(text.element.css("line-height")).to.equal("12px"); + text.destroy(); + }); + + /** + * test_author_windy + */ + it("handler", function (done) { + var text = BI.Test.createWidget({ + type: "bi.text", + text: "我是A", + handler: function () { + text.setText("handler"); + } + }); + BI.nextTick(function () { + text.text.element.click(); + expect(text.text.element.text()).to.equal("handler"); + text.destroy(); + done(); + }); + }); });