Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto substandard.blog
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031import { describe, expect, it } from 'vitest'
import { didFromAtUri, isOwnThread } from './gate'
const AUTHOR = 'did:plc:nlzmjyfv6loqtxyzvdcznwgf'const OTHER = 'did:plc:ewvi7nxzyoun6zhxrhs64oiz'const THREAD = `at://${AUTHOR}/app.bsky.feed.post/3mvohsymmis2b`
describe('didFromAtUri', () => { it('reads the authority of an at-uri', () => { expect(didFromAtUri(THREAD)).toBe(AUTHOR) })
it('rejects a non-at-uri or a handle authority', () => { expect(didFromAtUri('https://bsky.app/profile/alice.bsky.social')).toBeUndefined() expect(didFromAtUri('at://alice.bsky.social/app.bsky.feed.post/abc')).toBeUndefined() })})
describe('isOwnThread', () => { it('allows the author and refuses another account', () => { expect(isOwnThread(THREAD, AUTHOR)).toBe(true) expect(isOwnThread(THREAD, OTHER)).toBe(false) })
it('refuses an empty session or a malformed uri', () => { expect(isOwnThread(THREAD, '')).toBe(false) expect(isOwnThread('not-an-at-uri', AUTHOR)).toBe(false) })})