"use strict";

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

test('Function Rest Parameter', () => {
  const inputCode = `function sum(...args) {
  let sum = 0;
  for (let arg of args) sum += arg;
  return sum;
}
let x = sum(4, 9, 16, 25, 29, 100, 66, 77);`;
  const outputCode = `function sum() {
  let sum = 0;
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
    args[_key] = arguments[_key];
  }
  for (let arg of args) sum += arg;
  return sum;
}
let x = sum(4, 9, 16, 25, 29, 100, 66, 77);`;
  expect(convertCode(inputCode)).toBe(outputCode);
});