/* describe */

function compute(compareWith, toCompare) {
    if (compareWith[1] >= toCompare[0]) {
        if (compareWith[1] >= toCompare[1]) {
            return [compareWith];
        } else {
            return [[compareWith[0], toCompare[1]]];
        }
    } else {
        return [compareWith, toCompare];
    }
}

const scenarios = [
    {
        description: 'first case',
        input: [[2, 5], [4, 8], [10, 12]],
        output: [[2, 8], [10, 12]]
    },
    {
        description: 'second case',
        input: [[1, 3], [2, 4], [5, 7], [6, 8]],
        output: [[1, 4], [5, 8]]
    },
    {
        description: 'third case',
        input: [[6, 8], [1, 9], [2, 4], [4, 7]],
        output: [[1, 9]]
    },
    {
        description: 'fourth case',
        input: [[1,3], [2,6], [8,10], [15,18]],
        output: [[1,6], [8,10], [15,18]]
    },
    {
        description: 'fifth case',
        input: [[1,3], [3,6], [5,10], [15,18]],
        output: [[1,10], [15,18]]
    }
];

describe('Wrapper', () => {
    scenarios.forEach(({description, input, output}) => {
        describe(`Given ${description}`, () => {
            it('Then result', () => {
                input.sort((e1, e2) => e1[0] - e2[0]);
                let result = [input[0]];
                for (let i = 1; i < input.length; i++) {
                    const computed = compute(result.pop(), input[i]);
                    result = result.concat(computed);
                }
                expect(result).toEqual(output);
            });
        });
    });
});

@@ -13,316 +13,8 @@
 */%0A%0A
-function compute(compareWith, toCompare) %7B%0A    if (compareWith%5B1%5D %3E= toCompare%5B0%5D) %7B%0A        if (compareWith%5B1%5D %3E= toCompare%5B1%5D) %7B%0A            return %5BcompareWith%5D;%0A        %7D else %7B%0A            return %5B%5BcompareWith%5B0%5D, toCompare%5B1%5D%5D%5D;%0A        %7D%0A    %7D else %7B%0A        return %5BcompareWith, toCompare%5D;%0A    %7D%0A%7D%0A%0A
 cons
@@ -683,180 +683,379 @@
 %5D;%0A%0A
-describe('Wrapper', () =%3E %7B%0A    scenarios.forEach((%7Bdescription, input, output%7D) =%3E %7B%0A        describe(%60Given $%7Bdescription%7D%60, () =%3E %7B%0A            it('Then result', () =%3E %7B
+function mergeIntervals(input) %7B%0A%0A    const compute = (compareWith, toCompare) =%3E %7B%0A        if (compareWith%5B1%5D %3E= toCompare%5B0%5D) %7B%0A            if (compareWith%5B1%5D %3E= toCompare%5B1%5D) %7B%0A                return %5BcompareWith%5D;%0A            %7D else %7B%0A                return %5B%5BcompareWith%5B0%5D, toCompare%5B1%5D%5D%5D;%0A            %7D%0A        %7D else %7B%0A            return %5BcompareWith, toCompare%5D;
 %0A   
@@ -1055,28 +1055,34 @@
 e%5D;%0A        
+%7D%0A
     
+%7D;%0A%0A
     input.so
@@ -1108,36 +1108,24 @@
 %5D - e2%5B0%5D);%0A
-            
     let resu
@@ -1141,28 +1141,16 @@
 ut%5B0%5D%5D;%0A
-            
     for 
@@ -1194,28 +1194,16 @@
         
-     
-       
 const co
@@ -1256,71 +1256,265 @@
     
-  
+result = result.concat(computed);%0A
     
+%7D%0A
     
- 
+return
  result
- = result.concat(computed);%0A                %7D
+;%0A%7D%0A%0Adescribe('Given merge Intervals function', () =%3E %7B%0A    scenarios.forEach((%7Bdescription, input, output%7D) =%3E %7B%0A        describe(%60Given $%7Bdescription%7D%60, () =%3E %7B%0A            it('Then result', () =%3E %7B
 %0A   
@@ -1533,22 +1533,37 @@
  expect(
-result
+mergeIntervals(input)
 ).toEqua

Improve tests to be separated from functionality