From c863894f08c8fad6a913dd727b6c0aa23c3bd44c Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 2 Mar 2020 15:43:41 +0800 Subject: [PATCH] =?UTF-8?q?BI-52072=20test:=20=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bubblecombo/__test__/combo.bubble.test.js | 132 ++++++++++++++++++ .../__test__/combo.editiconcheck.test.js | 50 +++++++ .../__test__/combo.icontextvalue.test.js | 64 +++++++++ .../__test__/combo.textvalue.test.js | 118 ++++++++++++++++ .../__test__/timeinterval.test.js | 101 ++++++++++++++ 5 files changed, 465 insertions(+) create mode 100644 src/case/combo/bubblecombo/__test__/combo.bubble.test.js create mode 100644 src/case/combo/editoriconcheckcombo/__test__/combo.editiconcheck.test.js create mode 100644 src/case/combo/icontextvaluecombo/__test__/combo.icontextvalue.test.js create mode 100644 src/case/combo/textvaluecombo/__test__/combo.textvalue.test.js create mode 100644 src/widget/timeinterval/__test__/timeinterval.test.js diff --git a/src/case/combo/bubblecombo/__test__/combo.bubble.test.js b/src/case/combo/bubblecombo/__test__/combo.bubble.test.js new file mode 100644 index 000000000..f179f9a8b --- /dev/null +++ b/src/case/combo/bubblecombo/__test__/combo.bubble.test.js @@ -0,0 +1,132 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/2 + */ + +describe("bubble_combo", function () { + + /** + * test_author_windy + */ + it("测试弹出收起", function (done) { + var bubbleCombo = BI.Test.createWidget({ + type: "bi.bubble_combo", + el: { + type: "bi.button", + text: "测试", + height: 24 + }, + popup: { + el: { + type: "bi.button_group", + items: BI.makeArray(100, { + type: "bi.text_item", + height: 24, + text: "item" + }), + layouts: [{ + type: "bi.vertical" + }] + }, + maxHeight: 200 + } + }); + BI.nextTick(function () { + bubbleCombo.element.find(".bi-button").click(); + expect(bubbleCombo.element.find(".bi-bubble-popup-view").css("display")).to.equal("block"); + bubbleCombo.destroy(); + done(); + }) + }); + + /** + * test_author_windy + */ + it("测试弹出收起", function (done) { + var bubbleCombo = BI.Test.createWidget({ + type: "bi.bubble_combo", + el: { + type: "bi.button", + text: "测试", + height: 24 + }, + popup: { + el: { + type: "bi.button_group", + items: BI.makeArray(100, { + type: "bi.text_item", + height: 24, + text: "item" + }), + layouts: [{ + type: "bi.vertical" + }] + }, + maxHeight: 200 + } + }); + BI.nextTick(function () { + bubbleCombo.element.find(".bi-button").click(); + expect(bubbleCombo.element.find(".bi-bubble-popup-view").css("display")).to.equal("block"); + bubbleCombo.destroy(); + done(); + }) + }); + + + /** + * test_author_windy + */ + it("bubble_bar_popup_view", function (done) { + var bubbleCombo = BI.Test.createWidget({ + type: "bi.bubble_combo", + el: { + type: "bi.button", + text: "测试", + height: 24 + }, + popup: { + type: "bi.bubble_bar_popup_view", + el: { + type: "bi.vertical", + height: 40 + } + } + }); + BI.nextTick(function () { + bubbleCombo.element.find(".bi-button").click(); + expect(bubbleCombo.element.find(".bi-text:contains(确定)").length).to.equal(1); + bubbleCombo.destroy(); + done(); + }) + }); + + + /** + * test_author_windy + */ + it("text_bubble_bar_popup_view", function (done) { + var bubbleCombo = BI.Test.createWidget({ + type: "bi.bubble_combo", + el: { + type: "bi.button", + text: "测试", + height: 24 + }, + popup: { + type: "bi.text_bubble_bar_popup_view", + el: { + type: "bi.vertical", + height: 40 + } + } + }); + BI.nextTick(function () { + bubbleCombo.element.find(".bi-button").click(); + expect(bubbleCombo.element.find(".bi-text:contains(确定)").length).to.equal(1); + bubbleCombo.destroy(); + done(); + }) + }); +}); \ No newline at end of file diff --git a/src/case/combo/editoriconcheckcombo/__test__/combo.editiconcheck.test.js b/src/case/combo/editoriconcheckcombo/__test__/combo.editiconcheck.test.js new file mode 100644 index 000000000..72a0b9a9e --- /dev/null +++ b/src/case/combo/editoriconcheckcombo/__test__/combo.editiconcheck.test.js @@ -0,0 +1,50 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/2 + */ + +describe("edit_icon_check_combo", function () { + + /** + * test_author_windy + */ + it("测试弹出收起", function (done) { + var combo = BI.Test.createWidget({ + type: "bi.editor_icon_check_combo", + watermark: "默认值", + width: 200, + height: 24, + value: 2, + items: [{ + text: "MVC-1", + value: "1" + }, { + text: "MVC-2", + value: "2" + }, { + text: "MVC-3", + value: "3" + }] + }); + BI.nextTick(function () { + combo.element.find(".bi-editor-trigger").click(); + combo.element.find(".bi-text-icon-popup .bi-single-select-item").click(); + expect(combo.getValue()[0]).to.equal("3"); + combo.populate([{ + text: "MVC-1", + value: "4" + }, { + text: "MVC-2", + value: "5" + }, { + text: "MVC-3", + value: "6" + }]); + combo.setValue("4"); + expect(combo.getValue()[0]).to.equal("4"); + combo.destroy(); + done(); + }) + }); +}); \ No newline at end of file diff --git a/src/case/combo/icontextvaluecombo/__test__/combo.icontextvalue.test.js b/src/case/combo/icontextvaluecombo/__test__/combo.icontextvalue.test.js new file mode 100644 index 000000000..e53e81070 --- /dev/null +++ b/src/case/combo/icontextvaluecombo/__test__/combo.icontextvalue.test.js @@ -0,0 +1,64 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/2 + */ + +describe("icontextvaluecombo", function () { + + /** + * test_author_windy + */ + it("测试setValue", function () { + var combo = BI.Test.createWidget({ + type: "bi.icon_text_value_combo", + text: "默认值", + value: 22, + width: 300, + items: [{ + text: "MVC-1", + iconCls: "date-font", + value: 1 + }, { + text: "MVC-2", + iconCls: "search-font", + value: 2 + }, { + text: "MVC-3", + iconCls: "pull-right-font", + value: 3 + }] + }); + combo.setValue(2); + expect(combo.getValue()[0]).to.equal(2); + }); + + /** + * test_author_windy + */ + it("测试populate", function (done) { + var combo = BI.Test.createWidget({ + type: "bi.text_value_combo", + text: "默认值", + value: 22, + width: 300 + }); + combo.populate([{ + text: "MVC-1", + iconCls: "date-font", + value: 1 + }, { + text: "MVC-2", + iconCls: "search-font", + value: 2 + }, { + text: "MVC-3", + iconCls: "pull-right-font", + value: 3 + }]); + combo.setValue(2); + expect(combo.getValue()[0]).to.equal(2); + done(); + }); +}); + diff --git a/src/case/combo/textvaluecombo/__test__/combo.textvalue.test.js b/src/case/combo/textvaluecombo/__test__/combo.textvalue.test.js new file mode 100644 index 000000000..0166958fd --- /dev/null +++ b/src/case/combo/textvaluecombo/__test__/combo.textvalue.test.js @@ -0,0 +1,118 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/2 + */ + +describe("textvaluecombo", function () { + + /** + * test_author_windy + */ + it("测试setValue", function () { + var combo = BI.Test.createWidget({ + type: "bi.text_value_combo", + text: "默认值", + value: 22, + width: 300, + items: [{ + text: "MVC-1", + iconCls: "date-font", + value: 1 + }, { + text: "MVC-2", + iconCls: "search-font", + value: 2 + }, { + text: "MVC-3", + iconCls: "pull-right-font", + value: 3 + }] + }); + combo.setValue(2); + expect(combo.getValue()[0]).to.equal(2); + }); + + /** + * test_author_windy + */ + it("测试populate", function (done) { + var combo = BI.Test.createWidget({ + type: "bi.text_value_combo", + text: "默认值", + value: 22, + width: 300 + }); + combo.populate([{ + text: "MVC-1", + iconCls: "date-font", + value: 1 + }, { + text: "MVC-2", + iconCls: "search-font", + value: 2 + }, { + text: "MVC-3", + iconCls: "pull-right-font", + value: 3 + }]); + combo.setValue(2); + expect(combo.getValue()[0]).to.equal(2); + done(); + }); + + /** + * test_author_windy + */ + it("测试small_setValue", function () { + var combo = BI.Test.createWidget({ + type: "bi.small_text_value_combo", + text: "默认值", + value: 22, + width: 300, + items: [{ + text: "MVC-1", + iconCls: "date-font", + value: 1 + }, { + text: "MVC-2", + iconCls: "search-font", + value: 2 + }, { + text: "MVC-3", + iconCls: "pull-right-font", + value: 3 + }] + }); + combo.setValue(2); + expect(combo.getValue()[0]).to.equal(2); + }); + + /** + * test_author_windy + */ + it("测试small_populate", function (done) { + var combo = BI.Test.createWidget({ + type: "bi.small_text_value_combo", + text: "默认值", + value: 22, + width: 300 + }); + combo.populate([{ + text: "MVC-1", + iconCls: "date-font", + value: 1 + }, { + text: "MVC-2", + iconCls: "search-font", + value: 2 + }, { + text: "MVC-3", + iconCls: "pull-right-font", + value: 3 + }]); + combo.setValue(2); + expect(combo.getValue()[0]).to.equal(2); + done(); + }); +}); \ No newline at end of file diff --git a/src/widget/timeinterval/__test__/timeinterval.test.js b/src/widget/timeinterval/__test__/timeinterval.test.js new file mode 100644 index 000000000..c93714c53 --- /dev/null +++ b/src/widget/timeinterval/__test__/timeinterval.test.js @@ -0,0 +1,101 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/2/18 + */ + +describe("DateInterval", function () { + + /** + * test_author_windy + */ + it("DateInterval_defaultValue", function () { + var dateInterval = BI.Test.createWidget({ + type: "bi.date_interval", + value: { + 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("TimeInterval_defaultValue", function () { + var dateInterval = BI.Test.createWidget({ + type: "bi.time_interval", + value: { + start: { + type: 1, + value: { + year: 2018, + month: 1, + day: 12, + hour: 10, + minute: 10, + second: 10 + } + }, + end: { + type: 2, + value: { + year: -1, + position: 2 + } + } + }, + }); + expect(dateInterval.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-01-12 10:10:102019-01-01 00:00:00"); + dateInterval.destroy(); + }); + + /** + * test_author_windy + */ + it("TimePeriod_defaultValue", function () { + var dateInterval = BI.Test.createWidget({ + type: "bi.time_periods", + value: { + start: { + hour: 7, + minute: 23, + second: 14 + }, + end: { + hour: 23, + minute: 34, + second: 32 + } + }, + }); + expect(dateInterval.getValue()).to.deep.equal({ + "end": { + "hour": 23, + "minute": 34, + "second": 32 + }, + "start": { + "hour": 7, + "minute": 23, + "second": 14 + } + }); + dateInterval.destroy(); + }); +}); \ No newline at end of file