From 22462e828a7d3d2a6b4fd46aa91e7719898e60f9 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 12 Sep 2019 17:17:01 +0800 Subject: [PATCH] =?UTF-8?q?BI-51100=20test:=20=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor/__test__/editor.search.test.js | 32 ++++ .../editor/__test__/editor.text.test.js | 167 +++++++++++++++++- .../__test__/intervalslider.test.js | 36 ++++ src/widget/month/__test__/month.test.js | 31 ++++ 4 files changed, 265 insertions(+), 1 deletion(-) create mode 100644 src/widget/intervalslider/__test__/intervalslider.test.js create mode 100644 src/widget/month/__test__/month.test.js diff --git a/src/widget/editor/__test__/editor.search.test.js b/src/widget/editor/__test__/editor.search.test.js index 9e8c85d12..6228cd5aa 100644 --- a/src/widget/editor/__test__/editor.search.test.js +++ b/src/widget/editor/__test__/editor.search.test.js @@ -95,6 +95,22 @@ describe("searchEditor", function () { editor.destroy(); }); + /** + * test_author_windy + */ + it("getKeywords", function (done) { + var editor = BI.Test.createWidget({ + type: "bi.search_editor", + width: 300 + }); + editor.focus(); + BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8 8", 56, function () { + expect(editor.getKeywords()).to.deep.equal(["8", "8"]); + editor.destroy(); + done(); + }) + }); + /** * test_author_windy @@ -179,4 +195,20 @@ describe("searchEditor", function () { editor.destroy(); }); + /** + * test_author_windy + */ + it("getKeywords1", function (done) { + var editor = BI.Test.createWidget({ + type: "bi.search_editor", + width: 300 + }); + editor.focus(); + BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8 8", 56, function () { + expect(editor.getKeywords()).to.deep.equal(["8", "8"]); + editor.destroy(); + done(); + }) + }); + }); \ No newline at end of file diff --git a/src/widget/editor/__test__/editor.text.test.js b/src/widget/editor/__test__/editor.text.test.js index de00126d1..b1dd3a858 100644 --- a/src/widget/editor/__test__/editor.text.test.js +++ b/src/widget/editor/__test__/editor.text.test.js @@ -2,4 +2,169 @@ * @author windy * @version 2.0 * Created by windy on 2019/9/9 - */ \ No newline at end of file + */ +describe("textEditor", function () { + + /** + * test_author_windy + */ + it("defaultValue", function (done) { + var editor = BI.Test.createWidget({ + type: "bi.text_editor", + width: 300, + value: "12345", + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + expect(editor.element.find(".bi-water-mark").text()).to.equal("添加合法性判断"); + expect(editor.element.find(".bi-input").val()).to.equal("12345"); + editor.focus(); + BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () { + expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("长度必须大于4"); + editor.destroy(); + done(); + }) + }); + + /** + * test_author_windy + */ + it("setValue", function () { + var editor = BI.Test.createWidget({ + type: "bi.text_editor", + width: 300, + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + editor.setValue("12345"); + expect(editor.element.find(".bi-input").val()).to.equal("12345"); + editor.destroy(); + }); + + /** + * test_author_windy + */ + it("setErrorText", function (done) { + var editor = BI.Test.createWidget({ + type: "bi.text_editor", + width: 300, + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + editor.setErrorText("xin_error"); + editor.focus(); + BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () { + expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("xin_error"); + editor.destroy(); + done(); + }); + }); + + /** + * test_author_windy + */ + it("setWatermark", function () { + var editor = BI.Test.createWidget({ + type: "bi.text_editor", + width: 300, + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + editor.setWaterMark("xin_water"); + expect(editor.element.find(".bi-water-mark").text()).to.equal("xin_water"); + editor.destroy(); + }); + + /** + * test_author_windy + */ + it("getValue", function () { + var editor = BI.Test.createWidget({ + type: "bi.text_editor", + width: 300, + value: "12346", + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + expect(editor.getValue()).to.equal("12346"); + editor.destroy(); + }); + + + /** + * test_author_windy + */ + it("defaultValue1", function (done) { + var editor = BI.Test.createWidget({ + type: "bi.small_text_editor", + width: 300, + value: "12345", + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + expect(editor.element.find(".bi-water-mark").text()).to.equal("添加合法性判断"); + expect(editor.element.find(".bi-input").val()).to.equal("12345"); + editor.focus(); + BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () { + expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("长度必须大于4"); + editor.destroy(); + done(); + }) + }); + + /** + * test_author_windy + */ + it("setValue1", function () { + var editor = BI.Test.createWidget({ + type: "bi.small_text_editor", + width: 300, + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + editor.setValue("12345"); + expect(editor.element.find(".bi-input").val()).to.equal("12345"); + editor.destroy(); + }); + + + /** + * test_author_windy + */ + it("getValue1", function () { + var editor = BI.Test.createWidget({ + type: "bi.small_text_editor", + width: 300, + value: "12346", + watermark: "添加合法性判断", + errorText: "长度必须大于4", + validationChecker: function () { + return this.getValue().length > 4; + } + }); + expect(editor.getValue()).to.equal("12346"); + editor.destroy(); + }); + +}); \ No newline at end of file diff --git a/src/widget/intervalslider/__test__/intervalslider.test.js b/src/widget/intervalslider/__test__/intervalslider.test.js new file mode 100644 index 000000000..1555af80a --- /dev/null +++ b/src/widget/intervalslider/__test__/intervalslider.test.js @@ -0,0 +1,36 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/12 + */ +describe("intervalSlider", function () { + + /** + * test_author_windy + */ + it("defaultValue", function (done) { + var intervalSliderLabel = BI.Test.createWidget({ + type: "bi.interval_slider", + width: 300, + unit: "px", + cls: "layout-bg-white", + digit: 1 + }); + intervalSliderLabel.setMinAndMax({ + min: 0, + max: 120 + }); + intervalSliderLabel.setValue({ + min: 10, + max: 120 + }); + intervalSliderLabel.populate(); + BI.nextTick(function () { + expect(intervalSliderLabel.element.find(".sign-editor-text").get(0).innerHTML).to.equal("10.0px"); + expect(intervalSliderLabel.element.find(".sign-editor-text").get(1).innerHTML).to.equal("120.0px"); + intervalSliderLabel.destroy(); + done(); + }); + }); + +}); \ No newline at end of file diff --git a/src/widget/month/__test__/month.test.js b/src/widget/month/__test__/month.test.js new file mode 100644 index 000000000..af8800d76 --- /dev/null +++ b/src/widget/month/__test__/month.test.js @@ -0,0 +1,31 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2019/9/12 + */ + + +describe("month", function () { + + /** + * test_author_windy + */ + it("setValue", function () { + var combo = BI.Test.createWidget({ + type: "bi.month_combo", + }); + combo.setValue(11); + expect(combo.getValue()).to.equal(11); + }); + + /** + * test_author_windy + */ + it("getValue", function () { + var combo = BI.Test.createWidget({ + type: "bi.month_combo", + value: 1 + }); + expect(combo.getValue()).to.equal(1); + }); +}); \ No newline at end of file