diff --git a/packages/rspress-plugin-supersub/index.spec.ts b/packages/rspress-plugin-supersub/index.spec.ts new file mode 100644 index 0000000..94736d3 --- /dev/null +++ b/packages/rspress-plugin-supersub/index.spec.ts @@ -0,0 +1,40 @@ +import { test, expect } from '@playwright/test'; +import path from 'path'; +import { fileURLToPath } from 'url'; +import { runDevCommand, killProcess } from '../../e2e/utils.ts'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +test.describe('rspress-plugin-supersub', () => { + let devProcess: any; + let url: string; + + test.beforeAll(async () => { + const result = await runDevCommand(__dirname); + devProcess = result.process; + url = result.url; + }); + + test.afterAll(async () => { + if (devProcess) { + await killProcess(devProcess); + } + }); + + test('should render superscript with tag', async ({ page }) => { + await page.goto(url, { waitUntil: 'networkidle' }); + // Check if sup elements exist, which are generated by supersub plugin + // e.g., 2^10^ should render as 210 + const supElement = page.locator('sup'); + await expect(supElement.first()).toBeVisible(); + }); + + test('should render subscript with tag', async ({ page }) => { + await page.goto(url, { waitUntil: 'networkidle' }); + // Check if sub elements exist, which are generated by supersub plugin + // e.g., H_2_O should render as H2O + const subElement = page.locator('sub'); + await expect(subElement.first()).toBeVisible(); + }); +}); diff --git a/packages/rspress-plugin-supersub/vitest.config.ts b/packages/rspress-plugin-supersub/vitest.config.ts new file mode 100644 index 0000000..7b7f814 --- /dev/null +++ b/packages/rspress-plugin-supersub/vitest.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + exclude: ['**/*.spec.ts', 'node_modules'], + }, +});