forked from fanruan/fineui
Browse Source
* commit '5c09b2dc3da3adacbb1d02b74e5e2e4b313b396c': KERNEL-3477 test: 单测覆盖率53.2% REPORT-28235 fix: timeCombo %M:%S问题es6
windy
5 years ago
10 changed files with 290 additions and 2 deletions
@ -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(); |
||||
}); |
||||
}); |
@ -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); |
||||
}); |
||||
}); |
@ -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(); |
||||
}); |
||||
}); |
@ -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(); |
||||
}); |
||||
}); |
@ -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(); |
||||
}); |
||||
}); |
@ -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(); |
||||
}); |
||||
}); |
@ -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(); |
||||
}); |
||||
}); |
Loading…
Reference in new issue