mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-14 03:02:31 +00:00
greentext
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { account, status } from '$test/fixtures'
|
||||
import { accountForStatus, isHelenepost } from './heleneposting'
|
||||
|
||||
describe('Heleneposting detection', () => {
|
||||
it.each([
|
||||
'<p>A note<br>-Helene</p>',
|
||||
'<p>A note</p><p>-- Helene</p>',
|
||||
'<p>A note —<strong>Helene</strong></p>',
|
||||
'<blockquote>A note</blockquote><p>— Helene </p>',
|
||||
'<div><span class="h-card">@sun</span> that is woke —helene</div>',
|
||||
])('recognizes a signed HTML note: %s', (content) => {
|
||||
expect(isHelenepost(content)).toBe(true)
|
||||
})
|
||||
|
||||
it.each([
|
||||
'<p>Helene</p>',
|
||||
'<p>---Helene</p>',
|
||||
'<p>—Helene!</p>',
|
||||
'<p>—Helene wrote this</p>',
|
||||
'<p>—helen</p>',
|
||||
])('rejects content that is not an exact final signature: %s', (content) => {
|
||||
expect(isHelenepost(content)).toBe(false)
|
||||
})
|
||||
|
||||
it('substitutes presentation fields without changing account identity', () => {
|
||||
const original = account({
|
||||
id: 'actual-id',
|
||||
acct: 'actual@remote.test',
|
||||
display_name: 'Actual Author',
|
||||
avatar: 'https://remote.test/avatar.png',
|
||||
})
|
||||
const presented = accountForStatus(
|
||||
status({ account: original, content: '<p>Hello —Helene</p>' }),
|
||||
true,
|
||||
)
|
||||
|
||||
expect(presented).toMatchObject({
|
||||
id: 'actual-id',
|
||||
acct: 'actual@remote.test',
|
||||
display_name: 'Helene',
|
||||
})
|
||||
expect(presented.avatar).toContain('helene')
|
||||
expect(presented.avatar_static).toBe(presented.avatar)
|
||||
expect(original.display_name).toBe('Actual Author')
|
||||
})
|
||||
|
||||
it('does nothing while the feature is disabled', () => {
|
||||
const original = account()
|
||||
expect(
|
||||
accountForStatus(status({ account: original, content: '<p>—Helene</p>' }), false),
|
||||
).toBe(original)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user