"use strict";

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

test('string.includes() method', () => {
  const inputCode = `let text = "Hello world, welcome to the universe.";
text.includes("world")`;
  const outputCode = `let text = "Hello world, welcome to the universe.";
text.includes("world");`;
  expect(convertCode(inputCode)).toBe(outputCode);
});
test('string.startsWith() method', () => {
  const inputCode = `let text = "Hello world, welcome to the universe.";
text.startsWith("Hello")`;
  const outputCode = `let text = "Hello world, welcome to the universe.";
text.startsWith("Hello");`;
  expect(convertCode(inputCode)).toBe(outputCode);
});
test('string.endsWith() method', () => {
  const inputCode = `var text = "John Doe";
text.endsWith("Doe")`;
  const outputCode = `var text = "John Doe";
text.endsWith("Doe");`;
  expect(convertCode(inputCode)).toBe(outputCode);
});
test('Array.from method', () => {
  const inputCode = 'Array.from("ABCDEFG")  ';
  const outputCode = 'Array.from("ABCDEFG");';
  expect(convertCode(inputCode)).toBe(outputCode);
});
test('Array.keys method', () => {
  const inputCode = `const fruits = ["Banana", "Orange", "Apple", "Mango"];
const keys = fruits.keys();`;
  const outputCode = `const fruits = ["Banana", "Orange", "Apple", "Mango"];
const keys = fruits.keys();`;
  expect(convertCode(inputCode)).toBe(outputCode);
});
test('Array. finf method', () => {
  const inputCode = ` const numbers = [4, 9, 16, 25, 29];
let first = numbers.find(myFunction);

function myFunction(value, index, array) {
  return value > 18;
}`;
  const outputCode = `const numbers = [4, 9, 16, 25, 29];
let first = numbers.find(myFunction);
function myFunction(value, index, array) {
  return value > 18;
}`;
  expect(convertCode(inputCode)).toBe(outputCode);
});
test('Array.findIndex() method', () => {
  const inputCode = `const numbers = [4, 9, 16, 25, 29];
let first = numbers.findIndex(myFunction);

function myFunction(value, index, array) {
  return value > 18;
} `;
  const outputCode = `const numbers = [4, 9, 16, 25, 29];
let first = numbers.findIndex(myFunction);
function myFunction(value, index, array) {
  return value > 18;
}`;
  expect(convertCode(inputCode)).toBe(outputCode);
});