Last active
September 10, 2018 10:16
-
-
Save RayLuxembourg/b0f9b151d7a30161c6251ba41e361d67 to your computer and use it in GitHub Desktop.
more detailed test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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