Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('Utils', () => {
- let str;
- let compose;
- let filter;
- let map;
- let split;
- const { flip } = require('./../utils.js');
- beforeEach(() => {
- str = '1,2,30';
- compose = (...funcs) => {
- const fn = (str) => {
- return funcs.reduce((acc, func) => {
- acc = func(acc);
- return acc;
- }, str);
- };
- return fn;
- };
- const flipfn = flip(compose)(
- filter((x) => x > 10),
- map(Number),
- split(','),
- )(str);
- });
- describe('compose should', () => {
- it('return a new array', () => {
- // Arrange & Act
- const newComposition = flip(compose);
- // Assert
- expect(str).not.toEqual(newComposition);
- });
- it('return a new array with the composed elements', () => {
- // Arrange & Act
- const newCmp = flip(compose);
- // Assert
- expect(newCmp).not.toEqual(str);
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement