import rewiremock from 'rewiremock';
import '../../../mocks/electron';

import { expect } from 'chai';
import 'mocha';
import { isDev } from './env';

export function setDev(dev = true): void {
  if (dev) {
    process.argv.push('--env=dev');
  } else {
    process.argv = process.argv.filter((value) => value !== '--env=dev');
  }
}

describe('Environment Service', () => {
  before(() => {
    rewiremock.enable();
  });

  after(() => {
    rewiremock.disable();
  });

  it('correctly identifies the development process argument', () => {
    setDev();
    expect(isDev()).to.be.true;
    setDev(false);
    expect(isDev()).to.be.false;
  });
});
