Browse Source

BI-51100 test: 新增单测 && 删除无用代码

es6
windy 5 years ago
parent
commit
afe985c995
  1. 5
      dist/2.0/fineui.ie.js
  2. 5
      dist/2.0/fineui.js
  3. 5
      dist/bundle.ie.js
  4. 5
      dist/bundle.js
  5. 5
      dist/fineui.ie.js
  6. 5
      dist/fineui.js
  7. 5
      dist/fineui_without_jquery_polyfill.js
  8. 5
      dist/widget.js
  9. 1
      karma.conf.js
  10. 19
      src/widget/downlist/__test__/combo.downlist.test.js
  11. 119
      src/widget/dynamicdate/__test__/dynamicdate.combo.test.js
  12. 5
      src/widget/dynamicdate/dynamicdate.combo.js
  13. 25
      test/utils.js

5
dist/2.0/fineui.ie.js vendored

@ -64713,11 +64713,6 @@ BI.extend(BI.DynamicDateCard, {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK,
action: function () {
self.combo.toggle();
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
action: function () {

5
dist/2.0/fineui.js vendored

@ -65117,11 +65117,6 @@ BI.extend(BI.DynamicDateCard, {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK,
action: function () {
self.combo.toggle();
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
action: function () {

5
dist/bundle.ie.js vendored

@ -64713,11 +64713,6 @@ BI.extend(BI.DynamicDateCard, {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK,
action: function () {
self.combo.toggle();
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
action: function () {

5
dist/bundle.js vendored

@ -65117,11 +65117,6 @@ BI.extend(BI.DynamicDateCard, {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK,
action: function () {
self.combo.toggle();
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
action: function () {

5
dist/fineui.ie.js vendored

@ -64958,11 +64958,6 @@ BI.extend(BI.DynamicDateCard, {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK,
action: function () {
self.combo.toggle();
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
action: function () {

5
dist/fineui.js vendored

@ -65362,11 +65362,6 @@ BI.extend(BI.DynamicDateCard, {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK,
action: function () {
self.combo.toggle();
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
action: function () {

5
dist/fineui_without_jquery_polyfill.js vendored

@ -47661,11 +47661,6 @@ BI.extend(BI.DynamicDateCard, {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK,
action: function () {
self.combo.toggle();
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
action: function () {

5
dist/widget.js vendored

@ -2771,11 +2771,6 @@ BI.extend(BI.DynamicDateCard, {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK,
action: function () {
self.combo.toggle();
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
action: function () {

1
karma.conf.js

@ -18,6 +18,7 @@ module.exports = function (config) {
"src/css/theme/**/*.css",
"src/css/base/**/*.css",
"src/css/widget/**/*.css",
"public/css/app.css",
"src/core/foundation.js",
"src/core/lodash.js",
"src/core/base.js",

19
src/widget/downlist/__test__/combo.downlist.test.js

@ -0,0 +1,19 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/3
*/
describe("DownListCombo", function () {
/**
* test_author_windy
*/
it("defaultValue", function () {
var datePane = BI.Test.createWidget({
type: "bi.down_list_combo",
adjustLength: 10,
items: [[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":12},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}],[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":11},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}]]
});
});
});

119
src/widget/dynamicdate/__test__/dynamicdate.combo.test.js

@ -0,0 +1,119 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/4
*/
describe("DateCombo", function () {
/**
* test_author_windy
*/
it("defaultValue", function () {
var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo",
value: {
type: 1,
value: {
year: 2018,
month: 2,
day: 23
}
}
});
expect(dateCombo.element.find(".bi-date-trigger .bi-label").text()).to.equal("2018-02-23");
dateCombo.destroy();
});
/**
* test_author_windy
*/
it("测试输入值收起下拉清空值下拉出现", function (done) {
var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo",
width: 220,
height: 30,
value: {
type: 1,
value: {
year: 2018,
month: 2,
day: 23
}
}
});
BI.nextTick(function () {
dateCombo.element.find(".bi-date-trigger .bi-basic-button").click();
// 输入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");
// 清空输入, 检查popup是否弹出
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), "", BI.KeyCode.BACKSPACE, function () {
BI.nextTick(function () {
expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").css("display")).to.equal("block");
dateCombo.destroy();
done();
});
});
});
});
});
});
/**
* test_author_windy
*/
it("trigger的confirm-下拉面板选值confirm", function (done) {
var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo",
width: 220,
height: 30
});
// 点击日期,是否收起下拉
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");
dateCombo.destroy();
done();
})
});
/**
* test_author_windy
*/
it("trigger的输入日期后confirm", function (done) {
var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo",
width: 220,
height: 30,
value: {
type: 1,
value: {
year: 2018,
month: 2,
day: 23
}
}
});
BI.nextTick(function () {
dateCombo.element.find(".bi-date-trigger .bi-basic-button").click();
BI.nextTick(function () {
var input = dateCombo.element.find(".bi-date-trigger .bi-input");
input.val("2017-1-1");
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), null, BI.KeyCode.ENTER, function () {
BI.delay(function () {
expect(dateCombo.element.find(".bi-date-trigger .bi-text-button").text()).to.equal("2017-01-01");
dateCombo.destroy();
done();
}, 300);
});
});
})
});
});

5
src/widget/dynamicdate/dynamicdate.combo.js

@ -73,11 +73,6 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
self.combo.showView();
}
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK,
action: function () {
self.combo.toggle();
}
}, {
eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
action: function () {

25
test/utils.js

@ -7,6 +7,31 @@
}));
widget.element.appendTo("body");
return widget;
},
/**
* 模拟一次输入框的keydown事件
*/
triggerKeyDown: function (element, value, keyCode, callback) {
// keydown
var e = $.Event("keydown");
e.keyCode = keyCode;
element.trigger(e);
// input
BI.isNotNull(value) && element.val(value);
var e1 = $.Event("input");
e1.originalEvent = {};
e1.keyCode = keyCode;
element.trigger(e1);
// keyup 至少等300ms后触发
BI.delay(function () {
var e2 = jQuery.Event("keyup");
e2.keyCode = keyCode;
element.trigger(e2);
callback();
}, 300);
}
})
})();
Loading…
Cancel
Save