Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NikitK/ Payment agent store test #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 41 additions & 26 deletions src/__tests__/PaymentMethod.store.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,60 @@ import { fake_residence_list } from "./fakes/residence_list";

describe("Store", () => {
let store: PaymentMethodStore;
const payment_methods = fake_payment_methods.payment_methods
const residence_list = fake_residence_list.residence_list
const first_residence: IResidenceItem = fake_residence_list.residence_list[0]

beforeEach(() => {
store = new PaymentMethodStore();
});
store = new PaymentMethodStore()
})
afterEach(() => {
store.clear();
});
store.clear()
})

it("Should have loading as false", () => {
expect(store.loading).toBeFalsy();
});
expect(store.loading).toBeFalsy()
})

it("Should update country list", () => {
store.updateCountryList(fake_residence_list.residence_list);
expect(store.countryListStore).toHaveLength(
fake_residence_list.residence_list.length
);
expect(store.countryListStore).toEqual(fake_residence_list.residence_list);
});
store.updateCountryList(residence_list)

expect(store.countryListStore).toEqual(residence_list)
})

it("Should update the selected country", () => {
expect(true).toBeFalsy();
});
store.updateSelectedCountry(residence_list[0])

expect(store.selectedCountry).toEqual(first_residence)
})

it("Should have initial select country value on resetSelectedCountry", () => {
expect(true).toBeFalsy();
});
store.updateSelectedCountry(first_residence)
store.resetSelectedCountry()

expect(store.selectedCountry).toEqual(selectedCountryInitValue)
})

it("Should update payment methods", () => {
expect(true).toBeFalsy();
});
store.updatePaymentMethods(payment_methods)

expect(store.paymentMethods).toEqual(payment_methods)
})

it("Should clear payment methods on resetPaymentMethods", () => {
expect(true).toBeFalsy();
});
store.updatePaymentMethods(payment_methods)
store.resetPaymentMethods()

expect(store.paymentMethods).toEqual([])
})

it("Should have loading as falsy by default", () => {
expect(store.loading).toBeFalsy()
})

it("Should have loading as fulsy by default", () => {
expect(true).toBeFalsy();
});
it("Should have loading as truthy on toggleLoading", () => {
expect(true).toBeFalsy();
});
});
store.toggleLoading()

expect(store.loading).toBeTruthy()
})
})