Browse Source

BI-61182 test: 单测 && 修复virtual_list populate无效的问题

master
windy 5 years ago
parent
commit
bdc125a16f
  1. 2
      changelog.md
  2. 2
      src/base/list/virtuallist.js
  3. 102
      src/widget/timeinterval/__test__/timeinterval.test.js
  4. 44
      src/widget/yearmonthinterval/__test__/yearmonthinterval.test.js

2
changelog.md

@ -1,5 +1,7 @@
# 更新日志 # 更新日志
2.0(2020-04) 2.0(2020-04)
- 修复了复选下拉列表初始化的时候发送执行两次itemsCreator的问题
- 修复了virtual_list重新populate无效的问题
- 复选下拉框新增值的时候外抛事件 - 复选下拉框新增值的时候外抛事件
- 空格不再编码成&nbsp - 空格不再编码成&nbsp
- 支持文本区域水印可滚动 - 支持文本区域水印可滚动

2
src/base/list/virtuallist.js

@ -171,7 +171,7 @@ BI.VirtualList = BI.inherit(BI.Widget, {
if (items && this.options.items !== items) { if (items && this.options.items !== items) {
this.restore(); this.restore();
} }
this._populate(); this._populate(items);
}, },
destroyed: function () { destroyed: function () {

102
src/widget/timeinterval/__test__/timeinterval.test.js

@ -10,28 +10,70 @@ describe("DateInterval", function () {
* test_author_windy * test_author_windy
*/ */
it("DateInterval_defaultValue", function () { it("DateInterval_defaultValue", function () {
var dateInterval = BI.Test.createWidget({
type: "bi.date_interval"
});
dateInterval.setValue({
start: {
type: 1,
value: {
year: 2018,
month: 1,
day: 12
}
},
end: {
type: 2,
value: {
year: -1,
position: 2
}
}
});
expect(dateInterval.element.find(".bi-date-trigger .bi-label").text()).to.equal("2018-01-122019-01-01");
dateInterval.destroy();
});
/**
* test_author_windy
*/
it("DateInterval_测试报错", function (done) {
var testText;
var dateInterval = BI.Test.createWidget({ var dateInterval = BI.Test.createWidget({
type: "bi.date_interval", type: "bi.date_interval",
value: { value: {
start: { start: {
type: 1, type: 2,
value: { value: {
year: 2018, year: -1,
month: 1, position: 2
day: 12
} }
}, },
end: { end: {
type: 2, type: 1,
value: { value: {
year: -1, year: 2018,
position: 2 month: 1,
day: 12
} }
} }
}, },
listeners: [{
eventName: "EVENT_ERROR",
action: function () {
testText = "ERROR";
}
}]
}); });
expect(dateInterval.element.find(".bi-date-trigger .bi-label").text()).to.equal("2018-01-122019-01-01"); BI.nextTick(function () {
dateInterval.destroy(); dateInterval.element.find(".first-element .bi-date-trigger .bi-basic-button").click();
BI.delay(function () {
dateInterval.element.find(".first-element .bi-text-button:contains(确定)").click();
expect(testText).to.equal("ERROR");
dateInterval.destroy();
done();
}, 300);
})
}); });
/** /**
@ -98,4 +140,46 @@ describe("DateInterval", function () {
}); });
dateInterval.destroy(); dateInterval.destroy();
}); });
/**
* test_author_windy
*/
it("TimeInterval_测试报错", function (done) {
var testText;
var dateInterval = BI.Test.createWidget({
type: "bi.time_interval",
value: {
start: {
type: 2,
value: {
year: -1,
position: 2
}
},
end: {
type: 1,
value: {
year: 2018,
month: 1,
day: 12
}
}
},
listeners: [{
eventName: "EVENT_ERROR",
action: function () {
testText = "ERROR";
}
}]
});
BI.nextTick(function () {
dateInterval.element.find(".first-element .bi-date-time-trigger .bi-basic-button").click();
BI.delay(function () {
dateInterval.element.find(".first-element .bi-text-button:contains(确定)").click();
expect(testText).to.equal("ERROR");
dateInterval.destroy();
done();
}, 300);
})
});
}); });

44
src/widget/yearmonthinterval/__test__/yearmonthinterval.test.js

@ -60,7 +60,7 @@ describe("YearMonthInterval", function () {
*/ */
it("setValue", function () { it("setValue", function () {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_year_month_combo", type: "bi.year_month_interval",
width: 220, width: 220,
height: 30 height: 30
}); });
@ -99,4 +99,46 @@ describe("YearMonthInterval", function () {
dateCombo.destroy(); dateCombo.destroy();
}); });
/**
* test_author_windy
*/
it("错误提示", function (done) {
var testText;
var dateCombo = BI.Test.createWidget({
type: "bi.year_month_interval",
width: 220,
height: 30,
value: {
start: {
type: 2,
value: {
year: -1,
month: 1
}
},
end: {
type: 1,
value: {
year: 2018,
month: 1
}
}
},
listeners: [{
eventName: "EVENT_ERROR",
action: function () {
testText = "ERROR"
}
}]
});
dateCombo.element.find(".first-element .pull-down-font").click();
BI.delay(function () {
dateCombo.element.find(".bi-text-button:contains(确定)").click();
expect(testText).to.equal("ERROR");
dateCombo.destroy();
done();
}, 300);
});
}); });
Loading…
Cancel
Save