Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. describe('Utils', () => {
  2. let funcs = [];
  3. let arr;
  4. const { compose } = require('./../utils.js');
  5.  
  6. beforeEach(() => {
  7. arr = '1,2,3';
  8. const join = (args) => {
  9. const joined = (arr) => arr.join(args);
  10. return joined;
  11. };
  12. const concat = (arr2) => {
  13. const concatFn = (arr) => arr.concat(arr2);
  14. return concatFn;
  15. };
  16. funcs[0] = join;
  17. funcs[1] = concat;
  18. });
  19.  
  20. describe('compose should', () => {
  21. it('return a new array', () => {
  22. // Arrange & Act
  23. const newComposition = compose(...funcs);
  24.  
  25. // Assert
  26. expect(funcs).not.toEqual(newComposition);
  27. });
  28.  
  29. it('return a new array with the composed elements', () => {
  30. // Arrange & Act
  31. const newCmp = compose(...funcs)(arr);
  32. // Assert
  33. expect(newCmp).not.toEqual(arr);
  34. });
  35.  
  36. it('when executed should return a function', () => {
  37. // Arrange & Act
  38. const composeFn = compose(...funcs);
  39.  
  40. // Assert
  41. expect(composeFn).toBeInstanceOf(Function);
  42. });
  43. });
  44. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement