Guest User

Untitled

a guest
Aug 28th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. describe('addChat()', ({ test }) => {
  2. test('with no arguments', ({ same, end}) => {
  3. const msg = 'should add default chat message';
  4.  
  5. const actual = pipe(
  6. () => reducer(undefined, addChat()),
  7. // make sure the id and timestamp are there,
  8. // but we don't care about the values
  9. state => {
  10. const chat = state.chatLog[0];
  11. chat.id = !!chat.id;
  12. chat.timeStamp = !!chat.timeStamp;
  13. return state;
  14. }
  15. )();
  16.  
  17. const expected = Object.assign(createState(), {
  18. chatLog: [{
  19. id: true,
  20. user: 'Anonymous',
  21. msg: '',
  22. timeStamp: true
  23. }]
  24. });
  25.  
  26. same(actual, expected, msg);
  27. end();
  28. });
  29.  
  30.  
  31. test('with all arguments', ({ same, end}) => {
  32. const msg = 'should add correct chat message';
  33.  
  34. const actual = reducer(undefined, addChat({
  35. id: 1,
  36. user: '@JS_Cheerleader',
  37. msg: 'Yay!',
  38. timeStamp: 1472322852682
  39. }));
  40. const expected = Object.assign(createState(), {
  41. chatLog: [{
  42. id: 1,
  43. user: '@JS_Cheerleader',
  44. msg: 'Yay!',
  45. timeStamp: 1472322852682
  46. }]
  47. });
  48.  
  49. same(actual, expected, msg);
  50. end();
  51. });
  52. });
Add Comment
Please, Sign In to add comment