Browse Source

Merge pull request #1280 in VISUAL/fineui from ~WINDY/fineui:master to master

* commit '5c09b2dc3da3adacbb1d02b74e5e2e4b313b396c':
  KERNEL-3477 test: 单测覆盖率53.2%
  REPORT-28235 fix: timeCombo %M:%S问题
es6
windy 5 years ago
parent
commit
9851bd940b
  1. 1
      changelog.md
  2. 38
      src/base/collection/__test__/collection.test.js
  3. 33
      src/base/layer/__test__/layer.popover.test.js
  4. 23
      src/base/single/iframe/__test__/iframe.test.js
  5. 23
      src/base/single/img/__test__/img.test.js
  6. 19
      src/base/single/link/__test__/link.test.js
  7. 81
      src/case/pager/__test__/pager.test.js
  8. 33
      src/case/segment/__test__/segment.test.js
  9. 23
      src/widget/time/__test__/time.combo.test.js
  10. 18
      src/widget/time/time.trigger.js

1
changelog.md

@ -1,5 +1,6 @@
# 更新日志 # 更新日志
2.0(2020-03) 2.0(2020-03)
- 修复了time_combo设置格式为%M:%S后value设置大于30分钟的值时标红的问题
- 复选下拉树系列展开节点性能优化 - 复选下拉树系列展开节点性能优化
2.0(2020-02) 2.0(2020-02)

38
src/base/collection/__test__/collection.test.js

@ -0,0 +1,38 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/3/17
*/
describe("CollectionTest", function () {
/**
* test_author_windy
*/
it("collection", function () {
var items = [];
var cellCount = 100;
for (var i = 0; i < cellCount; i++) {
items[i] = {
type: "bi.label",
text: i
};
}
var grid = BI.Test.createWidget({
type: "bi.collection_view",
width: 400,
height: 300,
items: items,
cellSizeAndPositionGetter: function (index) {
return {
x: index % 10 * 50,
y: Math.floor(index / 10) * 50,
width: 50,
height: 50
};
}
});
// TODO 列表展示类控件不知道该测什么,先标记一下
grid.destroy();
});
});

33
src/base/layer/__test__/layer.popover.test.js

@ -0,0 +1,33 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/3/17
*/
describe("PopoverTest", function () {
/**
* test_author_windy
*/
it("BarPopover", function (done) {
var id = BI.UUID();
BI.Popovers.remove(id);
BI.Popovers.create(id, {
type: "bi.bar_popover",
size: "normal",
header: {
type: "bi.label",
text: "这个是header"
},
body: {
type: "bi.label",
text: "这个是body"
}
}).open(id);
BI.delay(function () {
expect(BI.Widget._renderEngine.createElement("body").find(".bi-popup-view .bi-z-index-mask").length).to.equal(1);
BI.Popovers.remove(id);
done();
}, 100);
});
});

23
src/base/single/iframe/__test__/iframe.test.js

@ -0,0 +1,23 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/3/17
*/
describe("IframeTest", function () {
/**
* test_author_windy
*/
it("directionPager", function () {
var a = BI.Test.createWidget({
type: "bi.iframe"
});
a.setSrc("http://www.baidu.com");
a.setName("testIFrame");
expect(a.element.attr("src"), "http://www.baidu.com");
expect(a.getSrc(), "http://www.baidu.com");
expect(a.getName(), "testIFrame");
a.destroy();
});
});

23
src/base/single/img/__test__/img.test.js

@ -0,0 +1,23 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/3/17
*/
describe("ImgTest", function () {
/**
* test_author_windy
*/
it("img", function () {
var a = BI.Test.createWidget({
type: "bi.img",
iconWidth: 36,
iconHeight: 36
});
a.setSrc("test.png");
expect(a.element.attr("src")).to.equal("test.png");
expect(a.getSrc()).to.equal("test.png");
a.destroy();
});
});

19
src/base/single/link/__test__/link.test.js

@ -0,0 +1,19 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/3/17
*/
describe("LinkTest", function () {
/**
* test_author_windy
*/
it("link", function () {
var a = BI.Test.createWidget({
type: "bi.link"
});
expect(a.element.is('a')).to.equal(true);
a.destroy();
});
});

81
src/case/pager/__test__/pager.test.js

@ -0,0 +1,81 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/3/17
*/
describe("PagerTest", function () {
/**
* test_author_windy
*/
it("allCountPager", function () {
var a = BI.Test.createWidget({
type: "bi.all_count_pager",
pages: 3,
curr: 1,
count: 1000
});
a.setCount(888);
expect(a.element.find(".row-count").text()).to.equal("888");
a.setAllPages(777);
a.setValue(4);
expect(a.element.find(".bi-input").val()).to.equal("4");
expect(a.getCurrentPage()).to.equal(4);
expect(a.hasPrev()).to.equal(false);
expect(a.hasNext()).to.equal(true);
a.populate();
expect(a.element.find(".bi-input").val()).to.equal("4");
a.setPagerVisible(false);
expect(a.element.find(".bi-pager").css("display")).to.equal("none");
a.destroy();
});
/**
* test_author_windy
*/
it("directionPager", function () {
var a = BI.Test.createWidget({
type: "bi.direction_pager",
horizontal: {
pages: false, // 总页数
curr: 1, // 初始化当前页, pages为数字时可用
hasPrev: function (v) {
return v > 1;
},
hasNext: function () {
return true;
},
firstPage: 1
},
vertical: {
pages: false, // 总页数
curr: 1, // 初始化当前页, pages为数字时可用
hasPrev: function (v) {
return v > 1;
},
hasNext: function () {
return true;
},
firstPage: 1
}
});
a.populate();
a.setVPage(2);
expect(a.getVPage()).to.equal(1);
a.setHPage(2);
expect(a.getHPage()).to.equal(1);
expect(a.hasVNext()).to.equal(true);
expect(a.hasHNext()).to.equal(true);
expect(a.hasVPrev()).to.equal(false);
expect(a.hasHPrev()).to.equal(false);
a.setHPagerVisible(false)
a.setVPagerVisible(false)
expect(a.element.find(".bi-pager").css("display")).to.equal("none");
a.clear();
a.destroy();
});
});

33
src/case/segment/__test__/segment.test.js

@ -0,0 +1,33 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/3/17
*/
describe("SegmentTest", function () {
/**
* test_author_windy
*/
it("segment", function () {
var a = BI.Test.createWidget({
type: "bi.segment",
items: [{
text: "1",
value: 1
}, {
text: "2",
value: 2
}, {
text: "3",
value: 3
}]
});
a.setValue(2);
expect(a.getValue()[0]).to.equal(2);
a.setEnable(false);
a.setEnabledValue(3);
a.setValue(3);
expect(a.getValue()[0]).to.equal(3);
a.destroy();
});
});

23
src/widget/time/__test__/time.combo.test.js

@ -168,4 +168,27 @@ describe("TimeCombo", function () {
}) })
}); });
/**
* test_author_windy
*/
it("测试%M:%S", function (done) {
var timeCombo = BI.Test.createWidget({
type: "bi.time_combo",
width: 220,
height: 30,
format: "%M:%S", // mm:ss
value: {
hour: 12,
minute: 45,
second: 0
},
});
BI.nextTick(function () {
expect(timeCombo.element.find(".bi-time-trigger .bi-label").text()).to.equal("45:00");
timeCombo.destroy();
done();
});
});
}); });

18
src/widget/time/time.trigger.js

@ -19,7 +19,8 @@
"%H:%M", // HH:mm "%H:%M", // HH:mm
"%M:%S" // mm:ss "%M:%S" // mm:ss
], ],
DEFAULT_DATE_STRING: "2000-01-01" DEFAULT_DATE_STRING: "2000-01-01",
DEFAULT_HOUR: "00"
}, },
props: { props: {
@ -135,11 +136,24 @@
_dateCheck: function (date) { _dateCheck: function (date) {
var c = this._const; var c = this._const;
var self = this;
return BI.any(c.FORMAT_ARRAY, function (idx, format) { return BI.any(c.FORMAT_ARRAY, function (idx, format) {
return BI.print(BI.parseDateTime(c.DEFAULT_DATE_STRING + " " + date, c.COMPLETE_COMPARE_FORMAT), format) === date; return BI.print(BI.parseDateTime(c.DEFAULT_DATE_STRING + " " + self._getCompleteHMS(date, format), c.COMPLETE_COMPARE_FORMAT), format) === date;
}); });
}, },
_getCompleteHMS: function (str, format) {
var c = this._const;
switch (format) {
case "%M:%S":
str = c.DEFAULT_HOUR + ":" + str;
break;
default:
break;
}
return str;
},
_getTitle: function () { _getTitle: function () {
var storeValue = this.storeValue || {}; var storeValue = this.storeValue || {};
var date = BI.getDate(); var date = BI.getDate();

Loading…
Cancel
Save