"use strict";

const {
  convertCode
} = require('../utilities');

test('array.flat()', () => {
  const inputCode = `const myArr = [[1,2],[3,4],[5,6]];
const newArr = myArr.flat();`;
  const outputCode = `const myArr = [[1, 2], [3, 4], [5, 6]];
const newArr = myArr.flat();`;
  expect(convertCode(inputCode)).toBe(outputCode);
});
test('array.flatMap()', () => {
  const inputCode = `const myArr = [1, 2, 3, 4, 5, 6];
    const newArr = myArr.flatMap((x) => x * 2); `;
  const outputCode = `const myArr = [1, 2, 3, 4, 5, 6];
const newArr = myArr.flatMap(x => x * 2);`;
  expect(convertCode(inputCode)).toBe(outputCode);
});
test('array.sort()', () => {
  const inputCode = `const numbers=[1,2,3,4,5,6];
numbers.sort((a,b)=>{
    return a-b;
})`;
  const outputCode = `const numbers = [1, 2, 3, 4, 5, 6];
numbers.sort((a, b) => {
  return a - b;
});`;
  expect(convertCode(inputCode)).toBe(outputCode);
});