mirror of
https://github.com/gromlab-ru/svg-sprites.git
synced 2026-07-22 04:40:17 +03:00
feat: добавить поддержку 20 framework exact modes
Добавлены exact modes: - vue@vite и vue@webpack - nuxt@vite и nuxt@webpack - svelte@vite, svelte@webpack и sveltekit@vite - angular@application и angular@webpack - astro@vite - solid@vite, solid@webpack и solid-start@vite - preact@vite и preact@webpack - qwik@vite - lit@vite и lit@webpack - alpine@vite и alpine@webpack Для каждого mode реализованы изолированный adapter, нативный framework-компонент, declarations, manifest, CSS и внешний asset URL. Добавлены production integration-стенды с генерацией, typecheck, сборкой и Playwright-проверкой рендера спрайта и Viewer. Обновлены Viewer, RU/EN-гайды, README, technical reference и AI skills. Итоговая матрица включает 29 exact modes. Проверки: - 48 unit-тестов - 29 integration E2E-тестов
This commit is contained in:
59
test/solid-modes.test.mjs
Normal file
59
test/solid-modes.test.mjs
Normal file
@@ -0,0 +1,59 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import test from 'node:test'
|
||||
|
||||
import { generateSprite, isSpriteMode } from '../dist/index.js'
|
||||
|
||||
const MODES = [
|
||||
{ mode: 'solid@vite', target: 'vite', asset: /sprite\.svg\?no-inline/ },
|
||||
{ mode: 'solid@webpack', target: 'webpack', asset: /new URL\('\.\.\/sprite\.svg', import\.meta\.url\)\.href/ },
|
||||
{ mode: 'solid-start@vite', target: 'vite', asset: /sprite\.svg\?no-inline/, ssr: true },
|
||||
]
|
||||
|
||||
function fixture() {
|
||||
const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), 'svg-sprites-solid-'))
|
||||
fs.mkdirSync(path.join(rootDir, 'icons'))
|
||||
fs.writeFileSync(
|
||||
path.join(rootDir, 'icons', 'check.svg'),
|
||||
'<svg viewBox="0 0 24 24"><path fill="#16a34a" d="M2 12l6 6L22 4" /></svg>',
|
||||
)
|
||||
return rootDir
|
||||
}
|
||||
|
||||
test('generates every isolated Solid family contract', async () => {
|
||||
for (const contract of MODES) {
|
||||
assert.equal(isSpriteMode(contract.mode), true)
|
||||
const result = await generateSprite(fixture(), {
|
||||
mode: contract.mode,
|
||||
name: 'app-icons',
|
||||
generatedNotice: false,
|
||||
})
|
||||
const componentPath = path.join(result.generatedDir, 'solid', 'solid-component.jsx')
|
||||
const component = fs.readFileSync(componentPath, 'utf8')
|
||||
const componentTypes = fs.readFileSync(path.join(result.generatedDir, 'solid', 'solid-component.d.ts'), 'utf8')
|
||||
const manifest = fs.readFileSync(result.manifestPath, 'utf8')
|
||||
|
||||
assert.equal(result.mode, contract.mode)
|
||||
assert.equal(result.target, contract.target)
|
||||
assert.deepEqual(fs.readdirSync(path.join(result.generatedDir, 'solid')).sort(), [
|
||||
'solid-component.d.ts',
|
||||
'solid-component.jsx',
|
||||
'solid-component.module.css',
|
||||
])
|
||||
assert.match(component, /import \{ Show, splitProps \} from 'solid-js'/)
|
||||
assert.match(component, /export const AppIconsIcon/)
|
||||
assert.match(component, contract.asset)
|
||||
assert.match(componentTypes, /Component<AppIconsIconProps>/)
|
||||
assert.match(manifest, /"framework": "solid(?:-start)?"/)
|
||||
assert.match(manifest, new RegExp(`"mode": ${JSON.stringify(contract.mode)}`))
|
||||
assert.doesNotMatch(component, /customElements|HTMLElement|gromlab-sprite-viewer/)
|
||||
assert.equal(fs.existsSync(path.join(result.generatedDir, 'solid', 'solid-component.tsx')), false)
|
||||
|
||||
if (contract.ssr) {
|
||||
assert.match(manifest, /"ssr": true/)
|
||||
assert.doesNotMatch(component, /\b(?:window|document|navigator|customElements)\b/)
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user