Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto substandard.blog
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344import { describe, expect, it } from 'vitest'import { badgeClass, badgeKindLabel, badgeMonogram } from './badge'
describe('badgeClass', () => { it('keeps one base class and adds the kind and size', () => { expect(badgeClass({ kind: 'publication' })).toBe('badge badge--publication badge--md') expect(badgeClass({ kind: 'account', size: 'sm' })).toBe('badge badge--account badge--sm') })
it('adds a tone only when it is not neutral', () => { expect(badgeClass({ kind: 'labeler', tone: 'neutral' })).not.toContain('badge--neutral') expect(badgeClass({ kind: 'labeler', tone: 'alert' })).toContain('badge--alert') })
it('adds the ghost and caller classes when asked', () => { expect(badgeClass({ kind: 'post', ghost: true, className: 'label-pill' })).toBe( 'badge badge--post badge--md badge--ghost label-pill', ) })})
describe('badgeMonogram', () => { it('uses the first visible character, without a leading @', () => { expect(badgeMonogram('@standard.site')).toBe('S') expect(badgeMonogram('permablog')).toBe('P') expect(badgeMonogram(' example ')).toBe('E') })
it('never returns an empty tile', () => { expect(badgeMonogram('')).toBe('·') expect(badgeMonogram('@')).toBe('·') })})
describe('badgeKindLabel', () => { it('names every kind for the tooltip and assistive text', () => { expect(badgeKindLabel('account')).toBe('Account') expect(badgeKindLabel('publication')).toBe('Publication') expect(badgeKindLabel('post')).toBe('Post') expect(badgeKindLabel('author')).toBe('Author') expect(badgeKindLabel('labeler')).toBe('Labeler') })})