Skip to content

Instantly share code, notes, and snippets.

@RayLuxembourg
Last active September 10, 2018 10:16
Show Gist options
  • Save RayLuxembourg/b0f9b151d7a30161c6251ba41e361d67 to your computer and use it in GitHub Desktop.
Save RayLuxembourg/b0f9b151d7a30161c6251ba41e361d67 to your computer and use it in GitHub Desktop.
more detailed test
//testing both success and fail status
it('should handle Add to bag Message', () => {
const msg: BagResponse = {
actionType: 'add',
category: 'bag',
product: { colorId: '01', productId: '23423', sizeId: 'SM003' },
status: 'success'
};
component.chooseMessageHandler(msg);
expect(component.bag[0]).toBe(component.buildIdentifier(msg.product));
component.bag = [];
msg.status = 'fail';
component.chooseMessageHandler(msg);
expect(component.bag[0]).toBeFalsy();
});
it('should handle remove from bag Message', () => {
const msg: BagResponse = {
actionType: 'remove',
category: 'bag',
product: { colorId: '01', productId: '23423', sizeId: 'SM003' },
status: 'fail'
};
component.add(component.buildIdentifier(msg.product));
component.chooseMessageHandler(msg);
expect(component.bag[0]).toBeTruthy();
msg.status = 'success';
component.chooseMessageHandler(msg);
expect(component.bag[0]).toBeFalsy();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment