chore: update dependencies and remove vitest

This commit is contained in:
DIYgod
2023-04-29 00:08:58 +01:00
parent b1a880cd34
commit d28faae2f9
5 changed files with 537 additions and 977 deletions
-90
View File
@@ -1,90 +0,0 @@
import { describe, expect, test } from "vitest"
import { renderPageContent } from "./index"
describe("html", () => {
test("simple", async () => {
const { contentHTML, excerpt } = await renderPageContent(
`
# Hello
This is the **excerpt**
> Hello Blockquote <sup>foo</sup>
- [ ] task list
- [x] done
<script>alert('xss')</script>
<img src="foo.png" alt="my image" onerror="console.log(1)" />
<figcaption><a href="https://example.com">my caption</a></figcaption>
<img src />
\`\`\`js
function foo() {}
<script>alert('xss')</script>
\`\`\`
\`\`\`
<script>alert('xss')</script>
\`\`\`
`,
true,
)
expect(contentHTML).not.toMatch(/<script>/)
expect(excerpt).toMatchInlineSnapshot(`
"This is the excerpt Hello Blockquote foo
task list done
my caption
Copy
function foo() {}
<script>alert('xss')</script>
C…"
`)
})
test("wrap table", async () => {
const { contentHTML } = await renderPageContent(
`|a|b|
|---|---|
|c|d|
`,
true,
)
expect(contentHTML.trim()).toMatchInlineSnapshot(
'"<div class=\\"table-wrapper\\"><table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>c</td><td>d</td></tr></tbody></table></div>"',
)
})
test("callout", async () => {
const { contentHTML } = await renderPageContent(
`
> TIP:
>
> Some tip!
> WARN:
>
> Some warning!
`,
true,
)
expect(contentHTML).toMatchInlineSnapshot(`
"<blockquote class=\\"callout callout-tip\\">
<p>Some tip!</p>
</blockquote>
<blockquote class=\\"callout callout-warn\\">
<p>Some warning!</p>
</blockquote>"
`)
})
})
-68
View File
@@ -1,68 +0,0 @@
import { describe, expect, test } from "vitest"
import removeMarkdown from "remove-markdown"
describe("remove markdown", () => {
test("remove image url but keep alt", () => {
expect(
removeMarkdown("![alt text](https://i.imgur.com/1ZQ3Q2l.jpg)", {
useImgAltText: true,
gfm: true,
}),
).toBe("alt text")
})
test("test markdown", () => {
expect(
removeMarkdown(
`# Heading 1
用 CSS 变量的颜色值。而 xLog 真巧使用了 Tailwind,基本上所有的颜色应用场景都用了 Tailwind 自带的色值,但由于 Tailwind 本身自带的色值都是一个 [固定的值](https://tailwindcss.com/docs/customizing-colors),并不支持根据 Dark Mode 切换色值。
于是我萌生了一个想法,让自带的颜色能根据是否是暗黑模式去切换就行了。
首先第一是,要重新配置 Tailwind,覆写原来内置的所有的颜色,把固定的值全部改写成 CSS 变量。变量的前缀可以自定义,不要冲突就行了,这边就暂定为 \`tw-colors-i\`。比如我们需要类似这样的色值配置:
\`\`\`js
// tailwind.config.ts
module.exports = {
theme: {
colors: {
slate: {
50: 'rgb(var(--tw-colors-i-slate-50))',
100: 'rgb(var(--tw-colors-i-slate-100))',
// ...
},
},
},
}
\`\`\``,
{
useImgAltText: true,
gfm: true,
},
),
).toMatchInlineSnapshot(`
"Heading 1
用 CSS 变量的颜色值。而 xLog 真巧使用了 Tailwind,基本上所有的颜色应用场景都用了 Tailwind 自带的色值,但由于 Tailwind 本身自带的色值都是一个 固定的值,并不支持根据 Dark Mode 切换色值。
于是我萌生了一个想法,让自带的颜色能根据是否是暗黑模式去切换就行了。
首先第一是,要重新配置 Tailwind,覆写原来内置的所有的颜色,把固定的值全部改写成 CSS 变量。变量的前缀可以自定义,不要冲突就行了,这边就暂定为 tw-colors-i。比如我们需要类似这样的色值配置:
// tailwind.config.ts
module.exports = {
theme: {
colors: {
slate: {
50: 'rgb(var(--tw-colors-i-slate-50))',
100: 'rgb(var(--tw-colors-i-slate-100))',
// ...
},
},
},
}
\`"
`)
})
})