import assert from 'node:assert/strict';
import test from 'node:test';
import { localizeGoogleFontsCss } from './mindspace-html-localize.mjs';

test('localizeGoogleFontsCss inlines google fonts imports', async () => {
  const source = `<!doctype html><html><head><style>
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC&display=swap');
body { color: red; }
</style></head><body>Hi</body></html>`;

  const result = await localizeGoogleFontsCss(source);
  assert.equal(result.localizedCount, 1);
  assert.match(result.html, /data-mindspace-local="google-fonts"/);
  assert.doesNotMatch(result.html, /@import\s+url\(['"]?https:\/\/fonts\.googleapis\.com/);
});
