diff --git a/components/tag/TagCard.vue b/components/tag/TagCard.vue index 1660d576..ed84bc53 100644 --- a/components/tag/TagCard.vue +++ b/components/tag/TagCard.vue @@ -39,8 +39,10 @@ function go(evt: MouseEvent | KeyboardEvent) {
const a = hello@@ -56,6 +57,62 @@ exports[`content-rich > code frame empty 1`] = `"
code frame no lang 1`] = `"hello world
no lang"`; +exports[`content-rich > collapse mentions 1`] = ` +"+ @elk + @elk + content + @antfu + @daniel + @sxzz + @patak + content +
+" +`; + exports[`content-rich > custom emoji 1`] = ` "Daniel Roegroup mention > html 1`] = ` class="u-url mention" rel="nofollow noopener noreferrer" to="/m.webtoo.ls/@pilipinas@lemmy.ml" - > + >@pilipinas " `; @@ -115,6 +177,39 @@ exports[`content-rich > handles html within code blocks 1`] = ` " `; +exports[`content-rich > hashtag adds bdi 1`] = ` +" + Testing bdi is added + #turkey +
+ +" +`; + +exports[`content-rich > hashtag doesn't add 2 bdi 1`] = ` +" + +" +`; + +exports[`content-rich > hides collapsed mentions 1`] = ` +"content
+" +`; + exports[`content-rich > inline code with link 1`] = ` "Inline code with link: @@ -139,8 +234,9 @@ exports[`content-rich > link + mention 1`] = ` class="u-url mention" rel="nofollow noopener noreferrer" to="/webtoo.ls/@vitest" - > + >@vitest (migrated from chai+mocha) plain text 1`] = ` " `; +exports[`content-rich > shows some collapsed mentions grouped 1`] = ` +"
+
+" +`; + +exports[`content-rich > shows some collapsed mentions inline 1`] = ` +"@antfu + @patak + @sxzz content ++ @antfu + content +
+" +`; + exports[`editor > transform mentions 1`] = ` " @elk Hello" diff --git a/tests/nuxt/content-rich.test.ts b/tests/nuxt/content-rich.test.ts index a2cf433e..1e52e672 100644 --- a/tests/nuxt/content-rich.test.ts +++ b/tests/nuxt/content-rich.test.ts @@ -89,55 +89,7 @@ describe('content-rich', () => { const { formatted } = await render('@elk @elk content @antfu @daniel @sxzz @patak content
', { collapseMentionLink: true, }) - expect(formatted).toMatchInlineSnapshot(` - "- - - content - - - - - content -
- " - `) + expect(formatted).toMatchSnapshot() }) it('hides collapsed mentions', async () => { @@ -145,10 +97,7 @@ describe('content-rich', () => { collapseMentionLink: true, inReplyToStatus: { account: { acct: 'elk@webtoo.ls' }, mentions: [] as mastodon.v1.StatusMention[] } as mastodon.v1.Status, }) - expect(formatted).toMatchInlineSnapshot(` - "content
- " - `) + expect(formatted).toMatchSnapshot() }) it('shows some collapsed mentions inline', async () => { @@ -156,19 +105,7 @@ describe('content-rich', () => { collapseMentionLink: true, inReplyToStatus: { account: { acct: 'elk@webtoo.ls' }, mentions: [] as mastodon.v1.StatusMention[] } as mastodon.v1.Status, }) - expect(formatted).toMatchInlineSnapshot(` - " - " - `) + expect(formatted).toMatchSnapshot() }) it('shows some collapsed mentions grouped', async () => { @@ -176,33 +113,7 @@ describe('content-rich', () => { collapseMentionLink: true, inReplyToStatus: { account: { acct: 'elk@webtoo.ls' }, mentions: [] as mastodon.v1.StatusMention[] } as mastodon.v1.Status, }) - expect(formatted).toMatchInlineSnapshot(` - " - " - `) + expect(formatted).toMatchSnapshot() }) it ('block with injected html, without language', async () => { @@ -237,6 +148,21 @@ describe('content-rich', () => { `) expect(formatted).toMatchSnapshot() }) + + it ('hashtag adds bdi', async () => { + const { formatted } = await render(` +Testing bdi is added #turkey
+ `) + expect(formatted).toMatchSnapshot() + }) + + // REVIEW: there is something wrong with this test in the rendered output, missing bdi content, ultrahtml parses it correctly + it ('hashtag doesn\'t add 2 bdi', async () => { + const { formatted } = await render(` +Testing bdi not added #turkey
+ `) + expect(formatted).toMatchSnapshot() + }) }) describe('editor', () => { @@ -273,8 +199,10 @@ async function render(content: string, options?: ContentParseOptions) { vi.mock('vue-router', async () => { const { defineComponent, h } = await import('vue') return { - RouterLink: defineComponent((attrs) => { - return () => h('a', attrs) + RouterLink: defineComponent({ + setup(props, { slots }) { + return () => h('a', props, { default: () => slots?.default?.() }) + }, }), } })