Browse Source

BI-61182 test: 单测

es6
windy 5 years ago
parent
commit
1bba5f1c5a
  1. 47
      src/base/foundation/__test__/message.test.js
  2. 42
      src/base/single/html/__test__/html.test.js
  3. 13
      src/case/colorchooser/__test__/colorchooser.test.js
  4. 1
      src/case/colorchooser/colorchooser.js

47
src/base/foundation/__test__/message.test.js

@ -0,0 +1,47 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/3/9
*/
describe("MessageTest", function () {
/**
* test_author_windy
*/
it("alert", function (done) {
BI.Msg.alert("message", "ASASASASA");
var body = BI.Widget._renderEngine.createElement("body");
expect(body.find(".bi-message-depend").length).to.equal(1);
BI.nextTick(function () {
body.find(".bi-message-depend .bi-button").click();
expect(body.find(".bi-message-depend").length).to.equal(0);
done();
});
});
/**
* test_author_windy
*/
it("toast_hand_close", function (done) {
BI.Msg.toast("message", {
autoClose: false
});
var body = BI.Widget._renderEngine.createElement("body");
expect(body.find(".bi-toast").length).to.equal(1);
BI.nextTick(function () {
body.find(".bi-toast .bi-icon-button").click();
expect(body.find(".bi-toast").length).to.equal(0);
done();
});
});
/**
* test_author_windy
*/
it("toast_auto_close", function () {
BI.Msg.toast("message");
var body = BI.Widget._renderEngine.createElement("body");
expect(body.find(".bi-toast").length).to.equal(1);
});
});

42
src/base/single/html/__test__/html.test.js

@ -0,0 +1,42 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/3/10
*/
describe("HtmlTest", function () {
/**
* test_author_windy
*/
it("html_h1", function () {
var a = BI.Test.createWidget({
type: "bi.html",
text: "<h1>在bi.html标签中使用html原生标签</h1>"
});
expect(a.element.find("h1").length).to.equal(1);
a.destroy();
});
/**
* test_author_windy
*/
it("html测试属性方法", function () {
var a = BI.Test.createWidget({
type: "bi.html",
text: "<h1>在bi.html标签中使用html原生标签</h1>",
height: 200,
width: 200,
value: "1",
highLight: true,
hgap: 10,
vgap: 10,
handler: BI.emptyFn
});
a.setValue("DDDDD");
a.setStyle({"background-color": "red"});
expect(a.text.element.css("background-color")).to.equal("rgb(255, 0, 0)");
a.destroy();
});
});

13
src/case/colorchooser/__test__/colorchooser.test.js

@ -36,4 +36,17 @@ describe("color_chooser_test", function () {
done(); done();
}, 300); }, 300);
}); });
/**
* test_author_windy
**/
it("默认值", function () {
var widget = BI.Test.createWidget({
type: "bi.color_chooser",
height: 24,
value: "#69821b"
});
expect(widget.getValue()).to.equal("#69821b");
widget.destroy();
});
}); });

1
src/case/colorchooser/colorchooser.js

@ -56,6 +56,7 @@ BI.ColorChooser = BI.inherit(BI.Widget, {
} }
}] }]
}, o.popup), }, o.popup),
value: o.value,
width: 230 width: 230
}, },
value: o.value value: o.value

Loading…
Cancel
Save