Advertisement
boris-ivanov

gre6en check flip

Jul 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. describe('Utils', () => {
  2. let str;
  3. let compose;
  4. let filter;
  5. let map;
  6. let split;
  7. const { flip } = require('./../utils.js');
  8.  
  9. beforeEach(() => {
  10. str = '1,2,30';
  11. compose = (...funcs) => {
  12. const fn = (str) => {
  13. return funcs.reduce((acc, func) => {
  14. acc = func(acc);
  15. return acc;
  16. }, str);
  17. };
  18. return fn;
  19. };
  20. const flipfn = flip(compose)(
  21. filter((x) => x > 10),
  22. map(Number),
  23. split(','),
  24. )(str);
  25. });
  26.  
  27. describe('compose should', () => {
  28. it('return a new array', () => {
  29. // Arrange & Act
  30. const newComposition = flip(compose);
  31.  
  32. // Assert
  33. expect(str).not.toEqual(newComposition);
  34. });
  35.  
  36. it('return a new array with the composed elements', () => {
  37. // Arrange & Act
  38. const newCmp = flip(compose);
  39. // Assert
  40. expect(newCmp).not.toEqual(str);
  41. });
  42. });
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement