Browse Source

BI-48725 test: 新增测试

es6
windy 5 years ago
parent
commit
e3ce228dba
  1. 9
      karma.conf.js
  2. 30
      src/base/__test__/a.test.js
  3. 73
      src/base/__test__/text.test.js

9
karma.conf.js

@ -17,6 +17,7 @@ module.exports = function (config) {
"src/css/core/**/*.css", "src/css/core/**/*.css",
"src/css/theme/**/*.css", "src/css/theme/**/*.css",
"src/css/base/**/*.css", "src/css/base/**/*.css",
"src/css/widget/**/*.css",
"src/core/foundation.js", "src/core/foundation.js",
"src/core/lodash.js", "src/core/lodash.js",
"src/core/base.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/listasynctree.js",
"src/base/tree/ztree/list/listparttree.js", "src/base/tree/ztree/list/listparttree.js",
"src/base/**/*.js", "src/base/**/*.js",
"src/case/**/*.js",
"src/widget/**/*.js",
"src/component/**/*.js",
"src/**/*.test.js", "src/**/*.test.js",
"test/**/*.js" "test/**/*.js"
], ],
@ -58,7 +62,10 @@ module.exports = function (config) {
"src/core/alias.js": "coverage", "src/core/alias.js": "coverage",
"src/core/base.js": "coverage", "src/core/base.js": "coverage",
"src/core/func/date.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"
}, },

30
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);
});
});

73
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); expect(text.element.children(".bi-keyword-red-mark").length).to.equal(0);
text.destroy(); 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();
});
});
}); });

Loading…
Cancel
Save