diff --git a/src/base/collection/__test__/collection.test.js b/src/base/collection/__test__/collection.test.js new file mode 100644 index 0000000000..381735ac32 --- /dev/null +++ b/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(); + }); +}); \ No newline at end of file diff --git a/src/base/layer/__test__/layer.popover.test.js b/src/base/layer/__test__/layer.popover.test.js new file mode 100644 index 0000000000..1830744a8f --- /dev/null +++ b/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); + }); +}); \ No newline at end of file diff --git a/src/base/single/iframe/__test__/iframe.test.js b/src/base/single/iframe/__test__/iframe.test.js new file mode 100644 index 0000000000..8e99a48a0b --- /dev/null +++ b/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(); + }); +}); \ No newline at end of file diff --git a/src/base/single/img/__test__/img.test.js b/src/base/single/img/__test__/img.test.js new file mode 100644 index 0000000000..d16ca92d82 --- /dev/null +++ b/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(); + }); +}); \ No newline at end of file diff --git a/src/base/single/link/__test__/link.test.js b/src/base/single/link/__test__/link.test.js new file mode 100644 index 0000000000..e425cb44bd --- /dev/null +++ b/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(); + }); +}); \ No newline at end of file diff --git a/src/case/pager/__test__/pager.test.js b/src/case/pager/__test__/pager.test.js new file mode 100644 index 0000000000..257e79272e --- /dev/null +++ b/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(); + }); +}); \ No newline at end of file diff --git a/src/case/segment/__test__/segment.test.js b/src/case/segment/__test__/segment.test.js new file mode 100644 index 0000000000..0b45ab53ab --- /dev/null +++ b/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(); + }); +}); \ No newline at end of file