"use strict";

const terser = require('terser');

test('reduce repeated variable names', () => {
  const code = `
    let number = 10;
    number = number+10;
`;
  return terser.minify(code).then(minify => {
    expect(minify.code).toBe('let number=10;number+=10;');
  });
});
test('variable names less than values with const', () => {
  const code = `
    const val = false;

    console.log(val);
`;
  return terser.minify(code).then(minify => {
    expect(minify.code).toBe('const val=!1;console.log(val);');
  });
});
test('variable names greather than values with const', () => {
  const code = `
    const found = true;

    console.log(found);
`;
  return terser.minify(code).then(minify => {
    expect(minify.code).toBe('const found=!0;console.log(true);');
  });
});
test('checking varible names with let and var', () => {
  const code = `
    let  val = false;

    var done = 3

    console.log(val,done);
`;
  return terser.minify(code).then(minify => {
    expect(minify.code).toBe('let val=!1;var done=3;console.log(val,done);');
  });
});