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

import {
  __resetSharpRuntimeForTests,
  getSharp,
  sharpLoadFailure,
} from './sharpRuntime.mjs';

void test('getSharp: loads sharp when install is healthy', () => {
  __resetSharpRuntimeForTests();
  const sharp = getSharp();
  assert.equal(typeof sharp, 'function');
});

void test('sharpLoadFailure: includes reinstall hint', () => {
  const err = sharpLoadFailure(new Error('SyntaxError: Unexpected end of input'));
  assert.match(err.message, /переустановите/i);
  assert.match(err.message, /SyntaxError/);
});
