import assert from 'node:assert/strict';
import test from 'node:test';

import { resolveIsProduction, resolveObfuscateMain } from './build-env.mjs';

void test('resolveIsProduction: argv --production', () => {
  assert.equal(resolveIsProduction(['node', 'scripts/build.mjs', '--production'], {}), true);
});

void test('resolveIsProduction: NODE_ENV=production', () => {
  assert.equal(resolveIsProduction(['node', 'scripts/build.mjs'], { NODE_ENV: 'production' }), true);
});

void test('resolveIsProduction: dev по умолчанию', () => {
  assert.equal(resolveIsProduction(['node', 'scripts/build.mjs'], { NODE_ENV: 'development' }), false);
});

void test('resolveObfuscateMain: --obfuscate', () => {
  assert.equal(resolveObfuscateMain(['node', 'build.mjs', '--production', '--obfuscate']), true);
  assert.equal(resolveObfuscateMain(['node', 'build.mjs', '--production']), false);
});
