Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('Utils', () => {
- let funcs = [];
- let arr;
- const { compose } = require('./../utils.js');
- beforeEach(() => {
- arr = '1,2,3';
- const join = (args) => {
- const joined = (arr) => arr.join(args);
- return joined;
- };
- const concat = (arr2) => {
- const concatFn = (arr) => arr.concat(arr2);
- return concatFn;
- };
- funcs[0] = join;
- funcs[1] = concat;
- });
- describe('compose should', () => {
- it('return a new array', () => {
- // Arrange & Act
- const newComposition = compose(...funcs);
- // Assert
- expect(funcs).not.toEqual(newComposition);
- });
- it('return a new array with the composed elements', () => {
- // Arrange & Act
- const newCmp = compose(...funcs)(arr);
- // Assert
- expect(newCmp).not.toEqual(arr);
- });
- it('when executed should return a function', () => {
- // Arrange & Act
- const composeFn = compose(...funcs);
- // Assert
- expect(composeFn).toBeInstanceOf(Function);
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement