Skip to content

Commit

Permalink
fix ut?
Browse files Browse the repository at this point in the history
  • Loading branch information
atlowChemi committed Jul 2, 2024
1 parent d38a7e5 commit 61b7dbe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ node_modules/
.idea

dist
src/fixtures/webfont-test/artifacts/*
11 changes: 10 additions & 1 deletion src/fixtures/vite.allowWriteFilesInBuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@ import { defineConfig } from 'vite';
import { viteSvgToWebfont } from '../../';

const webfontFolder = resolve(__dirname, './webfont-test/svg');
const outputFolder = resolve(__dirname, './webfont-test/artifacts');

export default defineConfig({
build: {
assetsInlineLimit: 0,
},
plugins: [viteSvgToWebfont({ context: webfontFolder, allowWriteFilesInBuild: true, fontName: 'allowWriteFilesInBuild-test', generateFiles: true })],
plugins: [
viteSvgToWebfont({
dest: outputFolder,
generateFiles: true,
context: webfontFolder,
allowWriteFilesInBuild: true,
fontName: 'allowWriteFilesInBuild-test',
}),
],
});
6 changes: 5 additions & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { constants } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { readFile, access } from 'node:fs/promises';
import { readFile, access, rmdir } from 'node:fs/promises';
import { describe, it, beforeAll, afterAll, expect } from 'vitest';
import { build, createServer, preview, normalizePath } from 'vite';
import type { RollupOutput } from 'rollup';
Expand Down Expand Up @@ -198,6 +198,10 @@ describe('build allowWriteFilesInBuild', () => {
await build(buildConfig);
});

afterAll(async () => {
rmdir(new URL('webfont-test/artifacts', root), { recursive: true });
});

it.concurrent.each([...types, 'html', 'css'])('has generated font of type %s', async type => {
const filePath = new URL(`webfont-test/artifacts/allowWriteFilesInBuild-test.${type}`, root);

Expand Down

0 comments on commit 61b7dbe

Please sign in to comment.