From 761a8c8cd83169ab254b8cc2b1fc79d54e484255 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Jan 2023 10:18:35 +0800 Subject: [PATCH 1/2] chore: implement tests --- src/__tests__/PaymentMethod.store.test.tsx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/__tests__/PaymentMethod.store.test.tsx b/src/__tests__/PaymentMethod.store.test.tsx index 0f0006c..013ba71 100644 --- a/src/__tests__/PaymentMethod.store.test.tsx +++ b/src/__tests__/PaymentMethod.store.test.tsx @@ -27,25 +27,35 @@ describe("Store", () => { }); it("Should update the selected country", () => { - expect(true).toBeFalsy(); + const selected_country: IResidenceItem = + fake_residence_list.residence_list[0]; + store.updateSelectedCountry(selected_country); + expect(store.selectedCountry).toEqual(selected_country); }); it("Should have initial select country value on resetSelectedCountry", () => { - expect(true).toBeFalsy(); + const selected_country = fake_residence_list.residence_list[0]; + store.updateSelectedCountry(selected_country); + store.resetSelectedCountry(); + expect(store.selectedCountry).toEqual(selectedCountryInitValue); }); it("Should update payment methods", () => { - expect(true).toBeFalsy(); + store.updatePaymentMethods(fake_payment_methods.payment_methods); + expect(store.paymentMethods).toEqual(fake_payment_methods.payment_methods); }); it("Should clear payment methods on resetPaymentMethods", () => { - expect(true).toBeFalsy(); + store.updatePaymentMethods(fake_payment_methods.payment_methods); + store.resetPaymentMethods(); + expect(store.paymentMethods).toEqual([]); }); it("Should have loading as fulsy by default", () => { - expect(true).toBeFalsy(); + expect(store.loading).toBeFalsy(); }); it("Should have loading as truthy on toggleLoading", () => { - expect(true).toBeFalsy(); + store.toggleLoading(); + expect(store.loading).toBeTruthy(); }); }); From 4b435dbc2deb0a206a09b6b4835c1a5d889b5634 Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Fri, 6 Jan 2023 10:23:17 +0800 Subject: [PATCH 2/2] chore: update selected country type --- src/__tests__/PaymentMethod.store.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/__tests__/PaymentMethod.store.test.tsx b/src/__tests__/PaymentMethod.store.test.tsx index 013ba71..7b267ca 100644 --- a/src/__tests__/PaymentMethod.store.test.tsx +++ b/src/__tests__/PaymentMethod.store.test.tsx @@ -34,7 +34,8 @@ describe("Store", () => { }); it("Should have initial select country value on resetSelectedCountry", () => { - const selected_country = fake_residence_list.residence_list[0]; + const selected_country: IResidenceItem = + fake_residence_list.residence_list[0]; store.updateSelectedCountry(selected_country); store.resetSelectedCountry(); expect(store.selectedCountry).toEqual(selectedCountryInitValue);