Commit e1848581 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch 'dz/351204-set-valid-quantity-on-purchase' into 'master'

Don't send empty string as quantity

See merge request gitlab-org/gitlab!79212
parents e14b7cce e8e71412
......@@ -47,7 +47,7 @@ export default {
return this.quantity || 0;
},
set(quantity) {
this.updateQuantity(quantity);
this.updateQuantity(quantity || 0);
},
},
isValid() {
......
......@@ -75,7 +75,7 @@ export default {
logError(error);
},
skip() {
return !this.purchaseHasExpiration;
return !this.purchaseHasExpiration || !this.quantity;
},
},
},
......
......@@ -32,6 +32,10 @@ describe('Order Summary', () => {
const findAmount = () => wrapper.findByTestId('amount');
const findTitle = () => wrapper.findByTestId('title');
const orderPreviewHandlerMock = jest
.fn()
.mockResolvedValue({ data: { orderPreview: mockOrderPreview } });
const createMockApolloProvider = (stateData = {}, mockRequest = {}) => {
const mockApollo = createMockApollo([], resolvers);
const data = merge({}, mockStateData, initialStateData, stateData);
......@@ -96,12 +100,9 @@ describe('Order Summary', () => {
describe('when subscription has expiration date', () => {
describe('calls api that returns prorated amount', () => {
beforeEach(async () => {
const orderPreviewQueryMock = jest
.fn()
.mockResolvedValue({ data: { orderPreview: mockOrderPreview } });
const apolloProvider = createMockApolloProvider(
{ subscription: { quantity: 1 } },
orderPreviewQueryMock,
orderPreviewHandlerMock,
);
createComponent(apolloProvider, { purchaseHasExpiration: true });
await waitForPromises();
......@@ -182,5 +183,19 @@ describe('Order Summary', () => {
expect(findAmount().text()).toBe('-');
});
});
describe('when subscription quantity is 0', () => {
beforeEach(() => {
const apolloProvider = createMockApolloProvider(
{ subscription: { quantity: 0 } },
orderPreviewHandlerMock,
);
createComponent(apolloProvider, { purchaseHasExpiration: true });
});
it('doesn not call api', () => {
expect(orderPreviewHandlerMock).not.toHaveBeenCalled();
});
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment