import { get_version, instance_id, package_json } from '../utils/constants';
import * as uuid from 'uuid';

test(`can read 'package.json'`, () => {
  console.log(package_json);
  expect(package_json).toBeDefined();
});

test(`'instance_id' is valid`, () => {
  console.log(instance_id);
  expect(instance_id).toBeDefined();
  expect(uuid.parse(instance_id)).toBeInstanceOf(Uint8Array);
});

test(`'version' can be read from 'package.json'`, () => {
  console.log(get_version());
  expect(get_version()).toBe('1.3.1-r3');
});

test(`'version' can be overridden by environment variable`, () => {
  console.log(process.env);
  process.env.REPERTORY_JS_FORCE_VERSION = '1.3.0';
  console.log(get_version());
  expect(get_version()).toBe('1.3.0');
  console.log(process.env);
});
