Adding store tests

This commit is contained in:
brydon1 2023-07-12 12:38:14 -04:00
parent 09adcc1114
commit 0ef1d5046d
4 changed files with 54 additions and 9 deletions

View file

@ -83,7 +83,7 @@
class="disclaimer-link"
linkType="text"
text="Terms of Use"
href="//www.safelite.com/terms-of-use" />{{ "." }}
href="//www.safelite.com/terms-of-use" />.
</p>
<siteFooter

View file

@ -1138,12 +1138,12 @@ export const useMainStore = defineStore({
},
updateContactInfo(contactInfo) {
this.order.contactInfo.firstName = contactInfo.firstName;
this.order.contactInfo.lastName = contactInfo.lastName;
this.order.contactInfo.emailAddress = contactInfo.emailAddress;
this.order.contactInfo.phoneNumber = contactInfo.phoneNumber;
this.order.contactInfo.requestTextUpdates = contactInfo.requestTextUpdates;
this.order.contactInfo.notesForTechnician = contactInfo.notesForTechnician;
this.order.contactInfo.firstName = contactInfo?.firstName ?? '';
this.order.contactInfo.lastName = contactInfo?.lastName ?? '';
this.order.contactInfo.emailAddress = contactInfo?.emailAddress ?? '';
this.order.contactInfo.phoneNumber = contactInfo?.phoneNumber ?? '';
this.order.contactInfo.requestTextUpdates = contactInfo?.requestTextUpdates ?? false;
this.order.contactInfo.notesForTechnician = contactInfo?.notesForTechnician ?? '';
},
GetExperimentsByUser(userId) {

View file

@ -424,6 +424,43 @@ describe("Store", () => {
});
});
// TODO add tests
describe('updateContactInfo method', () => {});
describe('updateContactInfo method', () => {
it('UpdateContactInfo updates contact info in store', () => {
// Arrange
const firstName = getRandomString(4, 10);
const lastName = getRandomString(5, 15);
const emailAddress = false;
const phoneNumber = getRandomInt(1000000000, 9999999999);
const requestTextUpdates = getRandomBoolean();
const notesForTechnician = getRandomString(50, 150);
// Act
store.updateContactInfo({ firstName,
lastName,
emailAddress,
phoneNumber,
requestTextUpdates,
notesForTechnician });
// Assert
expect(store.contactInfo.firstName).toEqual(firstName);
expect(store.contactInfo.lastName).toEqual(lastName);
expect(store.contactInfo.emailAddress).toEqual(emailAddress);
expect(store.contactInfo.phoneNumber).toEqual(phoneNumber);
expect(store.contactInfo.requestTextUpdates).toEqual(requestTextUpdates);
expect(store.contactInfo.notesForTechnician).toEqual(notesForTechnician);
});
it('All null values => contact info set in store to all nulls', () => {
// Act
store.updateContactInfo({});
// Assert
expect(store.contactInfo.firstName).toEqual('');
expect(store.contactInfo.lastName).toEqual('');
expect(store.contactInfo.emailAddress).toEqual('');
expect(store.contactInfo.phoneNumber).toEqual('');
expect(store.contactInfo.requestTextUpdates).toEqual(false);
expect(store.contactInfo.notesForTechnician).toEqual('');
});
});
});

View file

@ -75,4 +75,12 @@ describe("checkbox.vue", () => {
expect(paragraph.text()).toEqual("screenreader text");
});
it('Default isChecked is false', async () => {
// Act
const wrapper = shallowMount(checkbox, {});
// Assert
expect(wrapper.vm.isChecked).toEqual(false);
});
});