Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maybeanerd committed Jan 28, 2024
1 parent b510978 commit 1e1f23c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
22 changes: 11 additions & 11 deletions tests/nuxt/__snapshots__/content-rich.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ exports[`content-rich > collapse mentions 1`] = `
><a
class="u-url mention"
rel="nofollow noopener noreferrer"
to="/m.webtoo.ls/@elk"
to="/bumscode.com/@elk"
><bdi>@<span>elk</span></bdi></a
></span
>
<span class="h-card"
><a
class="u-url mention"
rel="nofollow noopener noreferrer"
to="/m.webtoo.ls/@elk"
to="/bumscode.com/@elk"
><bdi>@<span>elk</span></bdi></a
></span
>
Expand All @@ -80,7 +80,7 @@ exports[`content-rich > collapse mentions 1`] = `
><a
class="u-url mention"
rel="nofollow noopener noreferrer"
to="/m.webtoo.ls/@antfu"
to="/bumscode.com/@antfu"
><bdi>@<span>antfu</span></bdi></a
></span
>
Expand All @@ -96,15 +96,15 @@ exports[`content-rich > collapse mentions 1`] = `
><a
class="u-url mention"
rel="nofollow noopener noreferrer"
to="/m.webtoo.ls/@sxzz"
to="/bumscode.com/@sxzz"
><bdi>@<span>sxzz</span></bdi></a
></span
>
<span class="h-card"
><a
class="u-url mention"
rel="nofollow noopener noreferrer"
to="/m.webtoo.ls/@patak"
to="/bumscode.com/@patak"
><bdi>@<span>patak</span></bdi></a
></span
>
Expand Down Expand Up @@ -183,7 +183,7 @@ exports[`content-rich > hashtag adds bdi 1`] = `
<a
class="mention hashtag"
rel="nofollow noopener noreferrer"
to="/m.webtoo.ls/tags/turkey"
to="/bumscode.com/tags/turkey"
><bdi>#<span>turkey</span></bdi></a
>
</p>
Expand All @@ -197,7 +197,7 @@ exports[`content-rich > hashtag doesn't add 2 bdi 1`] = `
<a
class="mention hashtag"
rel="nofollow noopener noreferrer"
to="/m.webtoo.ls/tags/turkey"
to="/bumscode.com/tags/turkey"
><bdi></bdi
></a>
</p>
Expand Down Expand Up @@ -262,23 +262,23 @@ exports[`content-rich > shows some collapsed mentions grouped 1`] = `
><a
class="u-url mention"
rel="nofollow noopener noreferrer"
to="/m.webtoo.ls/@antfu"
to="/bumscode.com/@antfu"
><bdi>@<span>antfu</span></bdi></a
></span
>
<span class="h-card"
><a
class="u-url mention"
rel="nofollow noopener noreferrer"
to="/m.webtoo.ls/@patak"
to="/bumscode.com/@patak"
><bdi>@<span>patak</span></bdi></a
></span
>
<span class="h-card"
><a
class="u-url mention"
rel="nofollow noopener noreferrer"
to="/m.webtoo.ls/@sxzz"
to="/bumscode.com/@sxzz"
><bdi>@<span>sxzz</span></bdi></a
></span
></mention-group
Expand All @@ -293,7 +293,7 @@ exports[`content-rich > shows some collapsed mentions inline 1`] = `
><a
class="u-url mention"
rel="nofollow noopener noreferrer"
to="/m.webtoo.ls/@antfu"
to="/bumscode.com/@antfu"
><bdi>@<span>antfu</span></bdi></a
></span
>
Expand Down
10 changes: 5 additions & 5 deletions tests/nuxt/content-rich.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,30 +86,30 @@ describe('content-rich', () => {
})

it('collapse mentions', async () => {
const { formatted } = await render('<p><span class="h-card"><a href="https://m.webtoo.ls/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> <span class="h-card"><a href="https://m.webtoo.ls/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> content <span class="h-card"><a href="https://m.webtoo.ls/@antfu" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>antfu</span></a></span> <span class="h-card"><a href="https://mastodon.roe.dev/@daniel" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>daniel</span></a></span> <span class="h-card"><a href="https://m.webtoo.ls/@sxzz" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>sxzz</span></a></span> <span class="h-card"><a href="https://m.webtoo.ls/@patak" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>patak</span></a></span> content</p>', {
const { formatted } = await render('<p><span class="h-card"><a href="https://bumscode.com/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> <span class="h-card"><a href="https://bumscode.com/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> content <span class="h-card"><a href="https://bumscode.com/@antfu" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>antfu</span></a></span> <span class="h-card"><a href="https://mastodon.roe.dev/@daniel" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>daniel</span></a></span> <span class="h-card"><a href="https://bumscode.com/@sxzz" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>sxzz</span></a></span> <span class="h-card"><a href="https://bumscode.com/@patak" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>patak</span></a></span> content</p>', {
collapseMentionLink: true,
})
expect(formatted).toMatchSnapshot()
})

it('hides collapsed mentions', async () => {
const { formatted } = await render('<p><span class="h-card"><a href="https://m.webtoo.ls/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> content</p>', {
const { formatted } = await render('<p><span class="h-card"><a href="https://bumscode.com/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> content</p>', {
collapseMentionLink: true,
inReplyToStatus: { account: { acct: '[email protected]' }, mentions: [] as mastodon.v1.StatusMention[] } as mastodon.v1.Status,
})
expect(formatted).toMatchSnapshot()
})

it('shows some collapsed mentions inline', async () => {
const { formatted } = await render('<p><span class="h-card"><a href="https://m.webtoo.ls/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> <span class="h-card"><a href="https://m.webtoo.ls/@antfu" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>antfu</span></a></span> content</p>', {
const { formatted } = await render('<p><span class="h-card"><a href="https://bumscode.com/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> <span class="h-card"><a href="https://bumscode.com/@antfu" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>antfu</span></a></span> content</p>', {
collapseMentionLink: true,
inReplyToStatus: { account: { acct: '[email protected]' }, mentions: [] as mastodon.v1.StatusMention[] } as mastodon.v1.Status,
})
expect(formatted).toMatchSnapshot()
})

it('shows some collapsed mentions grouped', async () => {
const { formatted } = await render('<p><span class="h-card"><a href="https://m.webtoo.ls/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> <span class="h-card"><a href="https://m.webtoo.ls/@antfu" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>antfu</span></a></span> <span class="h-card"><a href="https://m.webtoo.ls/@patak" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>patak</span></a></span> <span class="h-card"><a href="https://m.webtoo.ls/@sxzz" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>sxzz</span></a></span>content</p>', {
const { formatted } = await render('<p><span class="h-card"><a href="https://bumscode.com/@elk" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>elk</span></a></span> <span class="h-card"><a href="https://bumscode.com/@antfu" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>antfu</span></a></span> <span class="h-card"><a href="https://bumscode.com/@patak" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>patak</span></a></span> <span class="h-card"><a href="https://bumscode.com/@sxzz" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>sxzz</span></a></span>content</p>', {
collapseMentionLink: true,
inReplyToStatus: { account: { acct: '[email protected]' }, mentions: [] as mastodon.v1.StatusMention[] } as mastodon.v1.Status,
})
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('content-rich', () => {

describe('editor', () => {
it('transform mentions', () => {
const ast = parseMastodonHTML('<p><span class="h-card"><a href="https://m.webtoo.ls/@elk" class="u-url mention">@<span>elk</span></a></span> Hello</p>')
const ast = parseMastodonHTML('<p><span class="h-card"><a href="https://bumscode.com/@elk" class="u-url mention">@<span>elk</span></a></span> Hello</p>')
const transformed = treeToText(ast)
expect(transformed).toMatchSnapshot()
})
Expand Down

0 comments on commit 1e1f23c

Please sign in to comment.