"use strict";

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

test('regex exec method', () => {
  const inputCode = `const str = "The quick brown fox jumps over the lazy dog.";
const regex = /quick (\\w+) fox/;

const result = regex.exec(str);`;
  const outputCode = `const str = "The quick brown fox jumps over the lazy dog.";
const regex = /quick (\\w+) fox/;
const result = regex.exec(str);`;
  expect(convertCode(inputCode)).toBe(outputCode);
});
test('unicode escape', () => {
  const inputCode = `const reGreekSymbol = /\\p{Script=Greek}/u;
reGreekSymbol.test('π');`;
  const outputCode = `const reGreekSymbol = /\\p{Script=Greek}/u;
reGreekSymbol.test('π');`;
  expect(convertCode(inputCode)).toBe(outputCode);
});
test('dot in regex', () => {
  const inputCode = '/./su;';
  const outputCode = '/./su;';
  expect(convertCode(inputCode)).toBe(outputCode);
});
test('named-capturing-groups-regex', () => {
  const inputCode = `var re = /(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})/;
console.log(re.exec("1999-02-29").groups.year);`;
  const outputCode = `var re = /(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})/;
console.log(re.exec("1999-02-29").groups.year);`;
  expect(convertCode(inputCode)).toBe(outputCode);
});