From 5cc64d994788ef7e06bcbc96a97b7b9fa9c8580e Mon Sep 17 00:00:00 2001 From: Ronmi Ren Date: Mon, 25 Jul 2016 22:43:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=9C=E4=B8=8A=E4=B8=80=E5=80=8B=20commit?= =?UTF-8?q?=20=E7=9A=84=E6=B8=AC=E8=A9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 這個 commit 可以看到我花那麼多 code 讓語意清楚的效果:這些修改只動到了自 己,修改 AuthForm 和 OrderForm 並不會讓 App 的測試碼也要跟著改動。 --- ui/test/AppTest.tsx | 18 +++++++++--------- ui/test/components/AuthFormTest.tsx | 6 +++--- ui/test/components/OrderFormTest.tsx | 20 ++++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ui/test/AppTest.tsx b/ui/test/AppTest.tsx index f979ac8..cc807cd 100644 --- a/ui/test/AppTest.tsx +++ b/ui/test/AppTest.tsx @@ -43,12 +43,12 @@ describe("", () => { describe("structure", () => { it("shows only AuthForm if not logged in", () => { let api = new FakeAPI(); - let wrapper = shallow({}} />); + let wrapper = shallow({}} />); expect(wrapper.find("AuthForm")).to.have.length(1); }); it("shows OrderForm, CurrencySelector and OrderList after loggedin", () => { let api = new FakeAPI(); - let wrapper = shallow({}} />); + let wrapper = shallow({}} />); wrapper.setState({authed: true, code: "", data: []}); wrapper.update(); expect(wrapper.find("OrderForm")).to.have.length(1); @@ -62,7 +62,7 @@ describe("", () => { let api = new FakeAPI(); api.will.success(); sinon.spy(api, "Auth"); - let wrapper = shallow({}} />); + let wrapper = shallow({}} />); helper.emitPincode(wrapper).then( check(done, () => { expect(api.Auth).has.been.calledOnce; @@ -75,7 +75,7 @@ describe("", () => { let api = new FakeAPI(); api.will.fail(); sinon.spy(api, "Auth"); - let wrapper = shallow({}} />); + let wrapper = shallow({}} />); helper.emitPincode(wrapper).then( () => { done(new Error("Unexpected api success with api.Auth")); }, check(done, () => { @@ -88,7 +88,7 @@ describe("", () => { api.will.success(); api.fakeData = [{when: 1, foreign: 1, local: -1, code: "USD"}]; sinon.spy(api, "ListAll"); - let wrapper = shallow({}} />); + let wrapper = shallow({}} />); helper.emitPincode(wrapper).then( check(done, () => { expect(api.ListAll).has.been.calledOnce; @@ -101,7 +101,7 @@ describe("", () => { let api = new FakeAPI(); api.will.success(); sinon.spy(api, "Add"); - let wrapper = shallow({}} />); + let wrapper = shallow({}} />); helper.emitPincode(wrapper).then( check(done, () => { wrapper.update(); @@ -119,7 +119,7 @@ describe("", () => { let order = {when:1, local: -1, foreign: 1, code: "USD"} let api = new FakeAPI(); api.will.success(); - let wrapper = shallow({}} />); + let wrapper = shallow({}} />); helper.emitPincode(wrapper).then( check(done, () => { wrapper.update(); @@ -138,7 +138,7 @@ describe("", () => { let order = {when:1, local: -1, foreign: 1, code: "USD"} let api = new FakeAPI(); api.will.success(); - let wrapper = shallow({}} />); + let wrapper = shallow({}} />); helper.emitPincode(wrapper).then( () => { wrapper.update(); @@ -160,7 +160,7 @@ describe("", () => { let api = new FakeAPI(); sinon.spy(api, "List"); api.will.success(); - let wrapper = shallow({}} />); + let wrapper = shallow({}} />); helper.emitPincode(wrapper).then( () => { wrapper.update(); diff --git a/ui/test/components/AuthFormTest.tsx b/ui/test/components/AuthFormTest.tsx index 478a0f7..3f5aa21 100644 --- a/ui/test/components/AuthFormTest.tsx +++ b/ui/test/components/AuthFormTest.tsx @@ -9,7 +9,7 @@ import AuthForm from "../../src/components/AuthForm"; let expect = chai.expect; describe("", () => { - let wrapper = shallow( {}} error={() => {}} />); + let wrapper = shallow( {}} formatError={() => {}} />); it("is a form", () => { expect(wrapper.is("form")).to.be.true; }); @@ -21,7 +21,7 @@ describe("", () => { }); it("emits submitPincode event when submitting 6 digit", () => { let s = sinon.spy(); - let wrapper = shallow( {}} />); + let wrapper = shallow( {}} />); wrapper.find('input[name="pin"]').simulate("change", {target: {value: 123456}}); wrapper.find("form").simulate("submit", {preventDefault: function(){}}); @@ -30,7 +30,7 @@ describe("", () => { it("emits only error event when submitting wrong format", () => { let s = sinon.spy(); let e = sinon.spy(); - let wrapper = shallow(); + let wrapper = shallow(); wrapper.find('input[name="pin"]').simulate("change", {target: {value: 1234567}}); wrapper.find("form").simulate("submit", {preventDefault: function(){}}); diff --git a/ui/test/components/OrderFormTest.tsx b/ui/test/components/OrderFormTest.tsx index a6b75be..91a29b9 100644 --- a/ui/test/components/OrderFormTest.tsx +++ b/ui/test/components/OrderFormTest.tsx @@ -75,10 +75,10 @@ describe("", () => { EV(wrapper.find('input[name="foreign"]'), "change", 100); wrapper.find('CurrencySelector').prop("codeSelected")("USD"); }; - it("emits only an error event when date format is invalid", () => { + it("emits only an format error event when date format is invalid", () => { let e = sinon.spy(); let s = sinon.spy(); - let wrapper = shallow(); + let wrapper = shallow(); preset(wrapper); EV(wrapper.find('input[name="when"]'), "change", "fail"); @@ -87,10 +87,10 @@ describe("", () => { expect(e).to.be.calledOnce; expect(s).not.to.be.called; }); - it("emits only an error event when foreign currency format is invalid", () => { + it("emits only an format error event when foreign currency format is invalid", () => { let e = sinon.spy(); let s = sinon.spy(); - let wrapper = shallow(); + let wrapper = shallow(); preset(wrapper); EV(wrapper.find('input[name="foreign"]'), "change", "fail"); @@ -99,10 +99,10 @@ describe("", () => { expect(e).to.be.calledOnce; expect(s).not.to.be.called; }); - it("emits only an error event when local currency format is invalid", () => { + it("emits only an format error event when local currency format is invalid", () => { let e = sinon.spy(); let s = sinon.spy(); - let wrapper = shallow(); + let wrapper = shallow(); preset(wrapper); EV(wrapper.find('input[name="local"]'), "change", "fail"); @@ -111,10 +111,10 @@ describe("", () => { expect(e).to.be.calledOnce; expect(s).not.to.be.called; }); - it("emits only an error event when both local and foreign currency are positive", () => { + it("emits only an format error event when both local and foreign currency are positive", () => { let e = sinon.spy(); let s = sinon.spy(); - let wrapper = shallow(); + let wrapper = shallow(); preset(wrapper); EV(wrapper.find('input[name="local"]'), "change", 3300); @@ -123,10 +123,10 @@ describe("", () => { expect(e).to.be.calledOnce; expect(s).not.to.be.called; }); - it("emits only an error event when both local and foreign currency are negative", () => { + it("emits only an format error event when both local and foreign currency are negative", () => { let e = sinon.spy(); let s = sinon.spy(); - let wrapper = shallow(); + let wrapper = shallow(); preset(wrapper); EV(wrapper.find('input[name="local"]'), "change", 3300);