forked from Mirrors/elk
chore: setup unit test
This commit is contained in:
parent
410d41a0a8
commit
15733000a6
5 changed files with 220 additions and 2 deletions
|
@ -11,10 +11,13 @@
|
|||
"lint": "eslint .",
|
||||
"postinstall": "nuxi prepare",
|
||||
"prepare": "esno scripts/prepare.ts",
|
||||
"generate": "nuxi generate"
|
||||
"generate": "nuxi generate",
|
||||
"test:unit": "vitest",
|
||||
"test": "nr test:unit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^0.31.0",
|
||||
"@antfu/ni": "^0.18.8",
|
||||
"@iconify-json/carbon": "^1.1.11",
|
||||
"@iconify-json/logos": "^1.1.19",
|
||||
"@iconify-json/ri": "^1.1.4",
|
||||
|
@ -25,6 +28,7 @@
|
|||
"@types/sanitize-html": "^2.6.2",
|
||||
"@types/wicg-file-system-access": "^2020.9.5",
|
||||
"@unocss/nuxt": "^0.46.5",
|
||||
"@vitejs/plugin-vue": "^3.2.0",
|
||||
"@vue-macros/nuxt": "^0.1.1",
|
||||
"@vueuse/nuxt": "^9.6.0",
|
||||
"blurhash": "^2.0.4",
|
||||
|
@ -46,6 +50,7 @@
|
|||
"shiki": "^0.11.1",
|
||||
"theme-vitesse": "^0.6.0",
|
||||
"typescript": "^4.9.3",
|
||||
"ufo": "^1.0.0"
|
||||
"ufo": "^1.0.0",
|
||||
"vitest": "^0.25.3"
|
||||
}
|
||||
}
|
||||
|
|
172
pnpm-lock.yaml
172
pnpm-lock.yaml
|
@ -2,6 +2,7 @@ lockfileVersion: 5.4
|
|||
|
||||
specifiers:
|
||||
'@antfu/eslint-config': ^0.31.0
|
||||
'@antfu/ni': ^0.18.8
|
||||
'@iconify-json/carbon': ^1.1.11
|
||||
'@iconify-json/logos': ^1.1.19
|
||||
'@iconify-json/ri': ^1.1.4
|
||||
|
@ -12,6 +13,7 @@ specifiers:
|
|||
'@types/sanitize-html': ^2.6.2
|
||||
'@types/wicg-file-system-access': ^2020.9.5
|
||||
'@unocss/nuxt': ^0.46.5
|
||||
'@vitejs/plugin-vue': ^3.2.0
|
||||
'@vue-macros/nuxt': ^0.1.1
|
||||
'@vueuse/nuxt': ^9.6.0
|
||||
blurhash: ^2.0.4
|
||||
|
@ -34,9 +36,11 @@ specifiers:
|
|||
theme-vitesse: ^0.6.0
|
||||
typescript: ^4.9.3
|
||||
ufo: ^1.0.0
|
||||
vitest: ^0.25.3
|
||||
|
||||
devDependencies:
|
||||
'@antfu/eslint-config': 0.31.0_hsf322ms6xhhd4b5ne6lb74y4a
|
||||
'@antfu/ni': 0.18.8
|
||||
'@iconify-json/carbon': 1.1.11
|
||||
'@iconify-json/logos': 1.1.19
|
||||
'@iconify-json/ri': 1.1.4
|
||||
|
@ -47,6 +51,7 @@ devDependencies:
|
|||
'@types/sanitize-html': 2.6.2
|
||||
'@types/wicg-file-system-access': 2020.9.5
|
||||
'@unocss/nuxt': 0.46.5
|
||||
'@vitejs/plugin-vue': 3.2.0
|
||||
'@vue-macros/nuxt': 0.1.1_nuxt@3.0.0
|
||||
'@vueuse/nuxt': 9.6.0_nuxt@3.0.0
|
||||
blurhash: 2.0.4
|
||||
|
@ -69,6 +74,7 @@ devDependencies:
|
|||
theme-vitesse: 0.6.0
|
||||
typescript: 4.9.3
|
||||
ufo: 1.0.0
|
||||
vitest: 0.25.3
|
||||
|
||||
packages:
|
||||
|
||||
|
@ -176,6 +182,11 @@ packages:
|
|||
find-up: 5.0.0
|
||||
dev: true
|
||||
|
||||
/@antfu/ni/0.18.8:
|
||||
resolution: {integrity: sha512-0m++AudwQq+wWAz/Ax7g+sh/wFW51HHQ6BtPLsuTAsFIzWB/bv/0COwZE7BRS+u0nqMb6Ks6nlk6cY1TpPDwHg==}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/@antfu/utils/0.5.2:
|
||||
resolution: {integrity: sha512-CQkeV+oJxUazwjlHD0/3ZD08QWKuGQkhnrKo3e6ly5pd48VUpXbb77q0xMU4+vc2CkJnDS02Eq/M9ugyX20XZA==}
|
||||
dev: true
|
||||
|
@ -1050,6 +1061,16 @@ packages:
|
|||
engines: {node: '>=10.13.0'}
|
||||
dev: true
|
||||
|
||||
/@types/chai-subset/1.3.3:
|
||||
resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==}
|
||||
dependencies:
|
||||
'@types/chai': 4.3.4
|
||||
dev: true
|
||||
|
||||
/@types/chai/4.3.4:
|
||||
resolution: {integrity: sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==}
|
||||
dev: true
|
||||
|
||||
/@types/estree/1.0.0:
|
||||
resolution: {integrity: sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==}
|
||||
dev: true
|
||||
|
@ -1906,6 +1927,11 @@ packages:
|
|||
acorn: 8.8.1
|
||||
dev: true
|
||||
|
||||
/acorn-walk/8.2.0:
|
||||
resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
dev: true
|
||||
|
||||
/acorn/8.8.1:
|
||||
resolution: {integrity: sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
|
@ -2056,6 +2082,10 @@ packages:
|
|||
es-shim-unscopables: 1.0.0
|
||||
dev: true
|
||||
|
||||
/assertion-error/1.1.0:
|
||||
resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==}
|
||||
dev: true
|
||||
|
||||
/ast-walker-scope/0.3.0:
|
||||
resolution: {integrity: sha512-bsOBv3jB+1kGaxwPHhkLiagS+75KfzEqtkNWvATgMGtXM6kJZG3PlG4fYQFMiHeLpoAkwc6G61w07+hEXx39aA==}
|
||||
engines: {node: '>=14.19.0'}
|
||||
|
@ -2283,6 +2313,19 @@ packages:
|
|||
upper-case-first: 2.0.2
|
||||
dev: true
|
||||
|
||||
/chai/4.3.7:
|
||||
resolution: {integrity: sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==}
|
||||
engines: {node: '>=4'}
|
||||
dependencies:
|
||||
assertion-error: 1.1.0
|
||||
check-error: 1.0.2
|
||||
deep-eql: 4.1.2
|
||||
get-func-name: 2.0.0
|
||||
loupe: 2.3.6
|
||||
pathval: 1.1.1
|
||||
type-detect: 4.0.8
|
||||
dev: true
|
||||
|
||||
/chalk/2.4.2:
|
||||
resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==}
|
||||
engines: {node: '>=4'}
|
||||
|
@ -2338,6 +2381,10 @@ packages:
|
|||
resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==}
|
||||
dev: true
|
||||
|
||||
/check-error/1.0.2:
|
||||
resolution: {integrity: sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==}
|
||||
dev: true
|
||||
|
||||
/chokidar/3.5.3:
|
||||
resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}
|
||||
engines: {node: '>= 8.10.0'}
|
||||
|
@ -2706,6 +2753,13 @@ packages:
|
|||
ms: 2.1.2
|
||||
dev: true
|
||||
|
||||
/deep-eql/4.1.2:
|
||||
resolution: {integrity: sha512-gT18+YW4CcW/DBNTwAmqTtkJh7f9qqScu2qFVlx7kCoeY9tlBu9cUcr7+I+Z/noG8INehS3xQgLpTtd/QUTn4w==}
|
||||
engines: {node: '>=6'}
|
||||
dependencies:
|
||||
type-detect: 4.0.8
|
||||
dev: true
|
||||
|
||||
/deep-is/0.1.4:
|
||||
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
|
||||
dev: true
|
||||
|
@ -3861,6 +3915,10 @@ packages:
|
|||
engines: {node: 6.* || 8.* || >= 10.*}
|
||||
dev: true
|
||||
|
||||
/get-func-name/2.0.0:
|
||||
resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==}
|
||||
dev: true
|
||||
|
||||
/get-intrinsic/1.1.3:
|
||||
resolution: {integrity: sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==}
|
||||
dependencies:
|
||||
|
@ -4700,6 +4758,12 @@ packages:
|
|||
is-unicode-supported: 1.3.0
|
||||
dev: true
|
||||
|
||||
/loupe/2.3.6:
|
||||
resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==}
|
||||
dependencies:
|
||||
get-func-name: 2.0.0
|
||||
dev: true
|
||||
|
||||
/lower-case/2.0.2:
|
||||
resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==}
|
||||
dependencies:
|
||||
|
@ -5504,6 +5568,10 @@ packages:
|
|||
resolution: {integrity: sha512-nPdMG0Pd09HuSsr7QOKUXO2Jr9eqaDiZvDwdyIhNG5SHYujkQHYKDfGQkulBxvbDHz8oHLsTgKN86LSwYzSHAg==}
|
||||
dev: true
|
||||
|
||||
/pathval/1.1.1:
|
||||
resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==}
|
||||
dev: true
|
||||
|
||||
/perfect-debounce/0.1.3:
|
||||
resolution: {integrity: sha512-NOT9AcKiDGpnV/HBhI22Str++XWcErO/bALvHCuhv33owZW/CjH8KAFLZDCmu3727sihe0wTxpDhyGc6M8qacQ==}
|
||||
dev: true
|
||||
|
@ -6496,6 +6564,12 @@ packages:
|
|||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/strip-literal/0.4.2:
|
||||
resolution: {integrity: sha512-pv48ybn4iE1O9RLgCAN0iU4Xv7RlBTiit6DKmMiErbs9x1wH6vXBs45tWc0H5wUIF6TLTrKweqkmYF/iraQKNw==}
|
||||
dependencies:
|
||||
acorn: 8.8.1
|
||||
dev: true
|
||||
|
||||
/strip-literal/1.0.0:
|
||||
resolution: {integrity: sha512-5o4LsH1lzBzO9UFH63AJ2ad2/S2AVx6NtjOcaz+VTT2h1RiRvbipW72z8M/lxEhcPHDBQwpDrnTF7sXy/7OwCQ==}
|
||||
dependencies:
|
||||
|
@ -6624,6 +6698,20 @@ packages:
|
|||
resolution: {integrity: sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==}
|
||||
dev: true
|
||||
|
||||
/tinybench/2.3.1:
|
||||
resolution: {integrity: sha512-hGYWYBMPr7p4g5IarQE7XhlyWveh1EKhy4wUBS1LrHXCKYgvz+4/jCqgmJqZxxldesn05vccrtME2RLLZNW7iA==}
|
||||
dev: true
|
||||
|
||||
/tinypool/0.3.0:
|
||||
resolution: {integrity: sha512-NX5KeqHOBZU6Bc0xj9Vr5Szbb1j8tUHIeD18s41aDJaPeC5QTdEhK0SpdpUrZlj2nv5cctNcSjaKNanXlfcVEQ==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
dev: true
|
||||
|
||||
/tinyspy/1.0.2:
|
||||
resolution: {integrity: sha512-bSGlgwLBYf7PnUsQ6WOc6SJ3pGOcd+d8AA6EUnLDDM0kWEstC1JIlSZA3UNliDXhd9ABoS7hiRBDCu+XP/sf1Q==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
dev: true
|
||||
|
||||
/tmp/0.0.33:
|
||||
resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==}
|
||||
engines: {node: '>=0.6.0'}
|
||||
|
@ -6702,6 +6790,11 @@ packages:
|
|||
prelude-ls: 1.2.1
|
||||
dev: true
|
||||
|
||||
/type-detect/4.0.8:
|
||||
resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==}
|
||||
engines: {node: '>=4'}
|
||||
dev: true
|
||||
|
||||
/type-fest/0.20.2:
|
||||
resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
@ -7123,6 +7216,85 @@ packages:
|
|||
fsevents: 2.3.2
|
||||
dev: true
|
||||
|
||||
/vite/3.2.4_@types+node@18.11.9:
|
||||
resolution: {integrity: sha512-Z2X6SRAffOUYTa+sLy3NQ7nlHFU100xwanq1WDwqaiFiCe+25zdxP1TfCS5ojPV2oDDcXudHIoPnI1Z/66B7Yw==}
|
||||
engines: {node: ^14.18.0 || >=16.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@types/node': '>= 14'
|
||||
less: '*'
|
||||
sass: '*'
|
||||
stylus: '*'
|
||||
sugarss: '*'
|
||||
terser: ^5.4.0
|
||||
peerDependenciesMeta:
|
||||
'@types/node':
|
||||
optional: true
|
||||
less:
|
||||
optional: true
|
||||
sass:
|
||||
optional: true
|
||||
stylus:
|
||||
optional: true
|
||||
sugarss:
|
||||
optional: true
|
||||
terser:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@types/node': 18.11.9
|
||||
esbuild: 0.15.15
|
||||
postcss: 8.4.19
|
||||
resolve: 1.22.1
|
||||
rollup: 2.79.1
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.2
|
||||
dev: true
|
||||
|
||||
/vitest/0.25.3:
|
||||
resolution: {integrity: sha512-/UzHfXIKsELZhL7OaM2xFlRF8HRZgAHtPctacvNK8H4vOcbJJAMEgbWNGSAK7Y9b1NBe5SeM7VTuz2RsTHFJJA==}
|
||||
engines: {node: '>=v14.16.0'}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@edge-runtime/vm': '*'
|
||||
'@vitest/browser': '*'
|
||||
'@vitest/ui': '*'
|
||||
happy-dom: '*'
|
||||
jsdom: '*'
|
||||
peerDependenciesMeta:
|
||||
'@edge-runtime/vm':
|
||||
optional: true
|
||||
'@vitest/browser':
|
||||
optional: true
|
||||
'@vitest/ui':
|
||||
optional: true
|
||||
happy-dom:
|
||||
optional: true
|
||||
jsdom:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@types/chai': 4.3.4
|
||||
'@types/chai-subset': 1.3.3
|
||||
'@types/node': 18.11.9
|
||||
acorn: 8.8.1
|
||||
acorn-walk: 8.2.0
|
||||
chai: 4.3.7
|
||||
debug: 4.3.4
|
||||
local-pkg: 0.4.2
|
||||
source-map: 0.6.1
|
||||
strip-literal: 0.4.2
|
||||
tinybench: 2.3.1
|
||||
tinypool: 0.3.0
|
||||
tinyspy: 1.0.2
|
||||
vite: 3.2.4_@types+node@18.11.9
|
||||
transitivePeerDependencies:
|
||||
- less
|
||||
- sass
|
||||
- stylus
|
||||
- sugarss
|
||||
- supports-color
|
||||
- terser
|
||||
dev: true
|
||||
|
||||
/vscode-jsonrpc/6.0.0:
|
||||
resolution: {integrity: sha512-wnJA4BnEjOSyFMvjZdpiOwhSq9uDoK8e/kpRJDTaMYzwlkrhG1fwDIZI94CLsLzlCK5cIbMMtFlJlfR57Lavmg==}
|
||||
engines: {node: '>=8.0.0 || >=10.0.0'}
|
||||
|
|
6
tests/__snapshots__/content.test.ts.snap
Normal file
6
tests/__snapshots__/content.test.ts.snap
Normal file
|
@ -0,0 +1,6 @@
|
|||
// Vitest Snapshot v1
|
||||
|
||||
exports[`rich-content > plain 1`] = `
|
||||
"Hello
|
||||
World"
|
||||
`;
|
21
tests/content.test.ts
Normal file
21
tests/content.test.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import type { Emoji } from 'masto'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { renderToString } from 'vue/server-renderer'
|
||||
import { contentToVNode } from '~/composables/content'
|
||||
|
||||
async function render(content: string, emojis?: Record<string, Emoji[]>) {
|
||||
const vnode = contentToVNode(content, emojis)
|
||||
const html = (await renderToString(vnode))
|
||||
.replace(/<!--[\[\]]-->/g, '')
|
||||
return {
|
||||
vnode,
|
||||
html,
|
||||
}
|
||||
}
|
||||
|
||||
describe('rich-content', () => {
|
||||
it('plain', async () => {
|
||||
const { html } = await render('Hello\nWorld')
|
||||
expect(html).toMatchSnapshot()
|
||||
})
|
||||
})
|
14
vitest.config.ts
Normal file
14
vitest.config.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { resolve } from 'path'
|
||||
import { defineConfig } from 'vitest/config'
|
||||
import Vue from '@vitejs/plugin-vue'
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
'~/': `${resolve(__dirname)}/`,
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
Vue(),
|
||||
],
|
||||
})
|
Loading…
Reference in a new issue