Browse Source

BI-52072 test: 钩子和单测修复

es6
windy 5 years ago
parent
commit
c7afb99a4e
  1. 8
      package.json
  2. 12
      src/core/platform/web/jquery/__test__/fn.test.js
  3. 6
      src/widget/dynamicdate/__test__/dynamicdate.test.js
  4. 4
      src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js

8
package.json

@ -40,6 +40,7 @@
"grunt-contrib-watch": "1.0.0",
"grunt-webpack": "3.1.3",
"html-webpack-plugin": "3.2.0",
"husky": "^3.1.0",
"karma": "3.1.4",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "2.2.0",
@ -86,5 +87,10 @@
"finebi"
],
"author": "fanruan",
"license": "MIT"
"license": "MIT",
"husky": {
"hooks": {
"pre-push": "npm run test"
}
}
}

12
src/core/platform/web/jquery/__test__/fn.test.js

@ -61,4 +61,16 @@ describe("标红test", function () {
expect(a.element.html()).to.equal("<span class=\"bi-keyword-red-mark\">a</span><span class=\"bi-keyword-red-mark\">啊</span>");
a.destroy();
});
/**
* test_author_windy
*/
it("中文拼音", function () {
var a = BI.Test.createWidget({
type: "bi.layout",
});
a.element.__textKeywordMarked__("日期", "日期");
expect(a.element.html()).to.equal("<span class=\"bi-keyword-red-mark\">日期</span>");
a.destroy();
});
});

6
src/widget/dynamicdate/__test__/dynamicdate.test.js

@ -54,7 +54,7 @@ describe("DateCombo", function () {
// 输入8, 检查popup是否收起
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), "8", 56, function () {
BI.nextTick(function () {
expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").css("display")).to.equal("none");
expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").length).to.equal(0);
// 清空输入, 检查popup是否弹出
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), "", BI.KeyCode.BACKSPACE, function () {
BI.nextTick(function () {
@ -82,7 +82,7 @@ describe("DateCombo", function () {
dateCombo.element.find(".bi-date-trigger .bi-basic-button").click();
BI.nextTick(function () {
dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(5)").parent().click();
expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").css("display")).to.equal("none");
expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").length).to.equal(0);
dateCombo.destroy();
done();
})
@ -105,7 +105,7 @@ describe("DateCombo", function () {
var input = dateCombo.element.find(".bi-date-trigger .bi-input");
BI.Test.triggerKeyDown(input, null, BI.KeyCode.ENTER, function () {
BI.delay(function () {
expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").css("display")).to.equal("none");
expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").length).to.equal(0);
dateCombo.destroy();
done();
}, 300);

4
src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js

@ -63,7 +63,7 @@ describe("DateTimeCombo", function () {
// 输入8, 检查popup是否收起
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), "8", 56, function () {
BI.nextTick(function () {
expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).to.equal("none");
expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").length).to.equal(0);
// 清空输入, 检查popup是否弹出
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), "", BI.KeyCode.BACKSPACE, function () {
BI.nextTick(function () {
@ -115,7 +115,7 @@ describe("DateTimeCombo", function () {
var input = dateCombo.element.find(".bi-date-time-trigger .bi-input");
BI.Test.triggerKeyDown(input, null, BI.KeyCode.ENTER, function () {
BI.delay(function () {
expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).to.equal("none");
expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").length).to.equal(0);
dateCombo.destroy();
done();
}, 300);

Loading…
Cancel
Save