formatting fixes
This commit is contained in:
parent
47dbab0941
commit
a831fa6c27
1 changed files with 205 additions and 206 deletions
|
|
@ -167,227 +167,226 @@ afterEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
Object.defineProperty(window, 'matchMedia', { value: jest.fn().mockImplementation((query) => ({
|
Object.defineProperty(window, 'matchMedia', { value: jest.fn().mockImplementation((query) => ({
|
||||||
matches: false,
|
matches: false,
|
||||||
media: query,
|
media: query,
|
||||||
onchange: null,
|
onchange: null,
|
||||||
addEventListener: jest.fn(),
|
addEventListener: jest.fn(),
|
||||||
removeEventListener: jest.fn(),
|
removeEventListener: jest.fn(),
|
||||||
dispatchEvent: jest.fn()
|
dispatchEvent: jest.fn()
|
||||||
})),
|
})),
|
||||||
writable: true });
|
writable: true });
|
||||||
|
});
|
||||||
|
describe('Initial Load', () => {
|
||||||
|
test('Should pass arePagePrerequisitesValid with a serviceLocation zipcode [in beforeEach]', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = getShallowMountedComponent();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(arePagePrerequisitesValid).toBe(true);
|
||||||
});
|
});
|
||||||
describe('Initial Load', () => {
|
test('Should fail arePagePrerequisitesValid with no serviceLocation zipcode', () => {
|
||||||
test('Should pass arePagePrerequisitesValid with a serviceLocation zipcode [in beforeEach]', () => {
|
// Arrange
|
||||||
// Arrange
|
const { wrapper } = getShallowMountedComponent();
|
||||||
const { wrapper } = getShallowMountedComponent();
|
wrapper.vm.mainStore.order.serviceLocation.zipCode = null;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(arePagePrerequisitesValid).toBe(true);
|
expect(arePagePrerequisitesValid).toBeFalsy();
|
||||||
});
|
});
|
||||||
test('Should fail arePagePrerequisitesValid with no serviceLocation zipcode', () => {
|
test('should return newShopTimeSlots when getAvailableDatesMethod is called', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getShallowMountedComponent();
|
const { wrapper } = getShallowMountedComponent();
|
||||||
wrapper.vm.mainStore.order.serviceLocation.zipCode = null;
|
wrapper.vm.selectableDatesData = {
|
||||||
|
days: []
|
||||||
// Act
|
};
|
||||||
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
const store = useMainStore();
|
||||||
|
store.getShopTimeSlots.mockImplementation(() => Promise.resolve({
|
||||||
// Assert
|
data: {
|
||||||
expect(arePagePrerequisitesValid).toBeFalsy();
|
estimatedServiceMinutesMinimum: 90,
|
||||||
});
|
estimatedServiceMinutesMaximum: 120,
|
||||||
test('should return newShopTimeSlots when getAvailableDatesMethod is called', async () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = getShallowMountedComponent();
|
|
||||||
wrapper.vm.selectableDatesData = {
|
|
||||||
days: []
|
|
||||||
};
|
|
||||||
const store = useMainStore();
|
|
||||||
store.getShopTimeSlots.mockImplementation(() => Promise.resolve({
|
|
||||||
data: {
|
|
||||||
estimatedServiceMinutesMinimum: 90,
|
|
||||||
estimatedServiceMinutesMaximum: 120,
|
|
||||||
days: [
|
|
||||||
{
|
|
||||||
date: '2023-12-01',
|
|
||||||
timeSlots: [
|
|
||||||
{
|
|
||||||
id: '06747-01820-S-B*20424*7 AM',
|
|
||||||
startTime: '07:00',
|
|
||||||
endTime: '08:00',
|
|
||||||
offerPremium: false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const newShopTimeSlots = await wrapper.vm.getAvailableDatesMethod(
|
|
||||||
'2023-01-01',
|
|
||||||
'2023-01-15'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(newShopTimeSlots).toStrictEqual({
|
|
||||||
days: [
|
days: [
|
||||||
{
|
{
|
||||||
date: '2023-12-01',
|
date: '2023-12-01',
|
||||||
timeSlots: [
|
timeSlots: [
|
||||||
{
|
{
|
||||||
endTime: '08:00',
|
|
||||||
id: '06747-01820-S-B*20424*7 AM',
|
id: '06747-01820-S-B*20424*7 AM',
|
||||||
offerPremium: false,
|
startTime: '07:00',
|
||||||
startTime: '07:00'
|
endTime: '08:00',
|
||||||
|
offerPremium: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const newShopTimeSlots = await wrapper.vm.getAvailableDatesMethod(
|
||||||
|
'2023-01-01',
|
||||||
|
'2023-01-15'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(newShopTimeSlots).toStrictEqual({
|
||||||
|
days: [
|
||||||
|
{
|
||||||
|
date: '2023-12-01',
|
||||||
|
timeSlots: [
|
||||||
|
{
|
||||||
|
endTime: '08:00',
|
||||||
|
id: '06747-01820-S-B*20424*7 AM',
|
||||||
|
offerPremium: false,
|
||||||
|
startTime: '07:00'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
estimatedServiceMinutesMinimum: 90,
|
||||||
|
estimatedServiceMinutesMaximum: 120
|
||||||
|
});
|
||||||
|
});
|
||||||
|
test('Should call API service in days of 15 or less when getAvailableDatesMethod is called with large date ranges', async () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = getShallowMountedComponent();
|
||||||
|
wrapper.vm.selectableDatesData = {
|
||||||
|
days: []
|
||||||
|
};
|
||||||
|
const store = useMainStore();
|
||||||
|
store.getShopTimeSlots.mockImplementation(() => Promise.resolve({
|
||||||
|
data: {
|
||||||
estimatedServiceMinutesMinimum: 90,
|
estimatedServiceMinutesMinimum: 90,
|
||||||
estimatedServiceMinutesMaximum: 120
|
estimatedServiceMinutesMaximum: 120,
|
||||||
});
|
|
||||||
});
|
|
||||||
test('Should call API service in days of 15 or less when getAvailableDatesMethod is called with large date ranges', async () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = getShallowMountedComponent();
|
|
||||||
wrapper.vm.selectableDatesData = {
|
|
||||||
days: []
|
days: []
|
||||||
};
|
}
|
||||||
const store = useMainStore();
|
}));
|
||||||
store.getShopTimeSlots.mockImplementation(() => Promise.resolve({
|
|
||||||
data: {
|
|
||||||
estimatedServiceMinutesMinimum: 90,
|
|
||||||
estimatedServiceMinutesMaximum: 120,
|
|
||||||
days: []
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.getAvailableDates.call(
|
await wrapper.vm.getAvailableDates.call(
|
||||||
wrapper.vm,
|
wrapper.vm,
|
||||||
'2023-01-01',
|
'2023-01-01',
|
||||||
'2023-03-31',
|
'2023-03-31',
|
||||||
'Inshop',
|
'Inshop',
|
||||||
'123',
|
'123',
|
||||||
'43228'
|
'43228'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// 2023-01-01 --> 2023-02-05
|
// 2023-01-01 --> 2023-02-05
|
||||||
// 2023-02-06 --> 2023-03-12
|
// 2023-02-06 --> 2023-03-12
|
||||||
// 2023-03-13 --> 2023-03-31
|
// 2023-03-13 --> 2023-03-31
|
||||||
expect(store.getShopTimeSlots).toHaveBeenCalledTimes(6);
|
expect(store.getShopTimeSlots).toHaveBeenCalledTimes(6);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('Rendering', () => {
|
describe('Rendering', () => {
|
||||||
test('Schedule page loads', () => {
|
test('Schedule page loads', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getShallowMountedComponent();
|
const { wrapper } = getShallowMountedComponent();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper).toBeTruthy();
|
expect(wrapper).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('schedule page methods...', () => {
|
describe('schedule page methods...', () => {
|
||||||
test('getServiceZipCtuCodeFromStore should return zipCodeCtu', () => {
|
test('getServiceZipCtuCodeFromStore should return zipCodeCtu', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getShallowMountedComponent();
|
const { wrapper } = getShallowMountedComponent();
|
||||||
wrapper.vm.selectableDatesData = {
|
wrapper.vm.selectableDatesData = {
|
||||||
days: []
|
days: []
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const testValue = wrapper.vm.getServiceZipCtuCodeFromStore();
|
const testValue = wrapper.vm.getServiceZipCtuCodeFromStore();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toStrictEqual('01234');
|
expect(testValue).toStrictEqual('01234');
|
||||||
});
|
});
|
||||||
test('forwardButtonAction should call route method navigate', async () => {
|
test('forwardButtonAction should call route method navigate', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getShallowMountedComponent();
|
const { wrapper } = getShallowMountedComponent();
|
||||||
wrapper.vm.$router.navigate = jest.fn(() => ({}));
|
wrapper.vm.$router.navigate = jest.fn(() => ({}));
|
||||||
wrapper.vm.mainStore.saveSchedule = jest.fn();
|
wrapper.vm.mainStore.saveSchedule = jest.fn();
|
||||||
wrapper.vm.navigationScenarios = {
|
wrapper.vm.navigationScenarios = {
|
||||||
CLICKED_FORWARD: 'CLICKED_FORWARD'
|
CLICKED_FORWARD: 'CLICKED_FORWARD'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mock the serviceLocation ref using Object.defineProperty to bypass readonly
|
// Mock the serviceLocation ref using Object.defineProperty to bypass readonly
|
||||||
Object.defineProperty(wrapper.vm.$refs, 'serviceLocation', {
|
Object.defineProperty(wrapper.vm.$refs, 'serviceLocation', {
|
||||||
value: {
|
value: {
|
||||||
forwardButtonAction: jest.fn()
|
forwardButtonAction: jest.fn()
|
||||||
},
|
},
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper.vm.selectedTimeSlotInfo = {
|
wrapper.vm.selectedTimeSlotInfo = {
|
||||||
timeSlot: {
|
timeSlot: {
|
||||||
routeCode: 'test-id'
|
routeCode: 'test-id'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
test('recalAckModal should open when part requires recal, but recal not added to order', async () => {
|
test('recalAckModal should open when part requires recal, but recal not added to order', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getShallowMountedComponent();
|
const { wrapper } = getShallowMountedComponent();
|
||||||
wrapper.vm.mainStore.lineItems.glassParts = [
|
wrapper.vm.mainStore.lineItems.glassParts = [
|
||||||
{
|
{
|
||||||
partNumber: 'TEST123',
|
partNumber: 'TEST123',
|
||||||
requiresRecalibration: true
|
requiresRecalibration: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$refs[RECAL_ACK_MODAL_REF_NAME].openModal).toHaveBeenCalled();
|
expect(wrapper.vm.$refs[RECAL_ACK_MODAL_REF_NAME].openModal).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
test('navigation forward is blocked when recalAckModal is displayed, but checkbox has not been acknowledged', async () => {
|
test('navigation forward is blocked when recalAckModal is displayed, but checkbox has not been acknowledged', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getShallowMountedComponent();
|
const { wrapper } = getShallowMountedComponent();
|
||||||
wrapper.vm.mainStore.lineItems.glassParts = [
|
wrapper.vm.mainStore.lineItems.glassParts = [
|
||||||
{
|
{
|
||||||
partNumber: 'TEST123',
|
partNumber: 'TEST123',
|
||||||
requiresRecalibration: true
|
requiresRecalibration: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
await wrapper.vm.$refs[RECAL_ACK_MODAL_REF_NAME].openModal();
|
await wrapper.vm.$refs[RECAL_ACK_MODAL_REF_NAME].openModal();
|
||||||
await wrapper.vm.$refs[RECAL_ACK_MODAL_REF_NAME].footerButtonClick();
|
await wrapper.vm.$refs[RECAL_ACK_MODAL_REF_NAME].footerButtonClick();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate).not.toHaveBeenCalled();
|
expect(wrapper.vm.$router.navigate).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
test('navigation forward is allowed when checkbox has been acknowledged on recalAckModal', async () => {
|
test('navigation forward is allowed when checkbox has been acknowledged on recalAckModal', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = getShallowMountedComponent();
|
const { wrapper } = getShallowMountedComponent();
|
||||||
wrapper.vm.mainStore.lineItems.glassParts = [
|
wrapper.vm.mainStore.lineItems.glassParts = [
|
||||||
{
|
{
|
||||||
partNumber: 'TEST123',
|
partNumber: 'TEST123',
|
||||||
requiresRecalibration: true
|
requiresRecalibration: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.$refs[RECAL_ACK_MODAL_REF_NAME].openModal();
|
await wrapper.vm.$refs[RECAL_ACK_MODAL_REF_NAME].openModal();
|
||||||
wrapper.vm.updateIsRecalAcknowledged(true);
|
wrapper.vm.updateIsRecalAcknowledged(true);
|
||||||
await wrapper.vm.$refs[RECAL_ACK_MODAL_REF_NAME].footerButtonClick();
|
await wrapper.vm.$refs[RECAL_ACK_MODAL_REF_NAME].footerButtonClick();
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue