mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|||
|
|
import { KNOWN_5CHAN_DEVELOPER_ENTRIES, getAuthorBadge, isKnown5chanDeveloper } from '../author-display-utils';
|
||
|
|
|
||
|
|
describe('author display utils', () => {
|
||
|
|
it('recognizes the hardcoded 5chan developer addresses', () => {
|
||
|
|
expect(isKnown5chanDeveloper('estebanabaroa.bso')).toBe(true);
|
||
|
|
expect(isKnown5chanDeveloper('rinse12.bso')).toBe(true);
|
||
|
|
expect(isKnown5chanDeveloper('plebeius.bso')).toBe(true);
|
||
|
|
expect(isKnown5chanDeveloper('someone-else.bso')).toBe(false);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('keeps optional developer profile metadata next to the hardcoded address', () => {
|
||
|
|
expect(KNOWN_5CHAN_DEVELOPER_ENTRIES).toContainEqual({
|
||
|
|
address: 'rinse12.bso',
|
||
|
|
githubProfileUrl: 'https://github.com/rinse12',
|
||
|
|
name: 'Rinse',
|
||
|
|
});
|
||
|
|
expect(KNOWN_5CHAN_DEVELOPER_ENTRIES).toContainEqual({
|
||
|
|
address: 'plebeius.bso',
|
||
|
|
githubProfileUrl: 'https://github.com/tomcasaburi',
|
||
|
|
name: 'Tommaso Casaburi',
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
it('labels known developers with the admin icon style', () => {
|
||
|
|
expect(getAuthorBadge({ address: 'rinse12.bso' })).toEqual({
|
||
|
|
icon: 'admin',
|
||
|
|
label: '5chan Dev',
|
||
|
|
title: '5chan Dev',
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
it('keeps the developer label even when the account has a board role', () => {
|
||
|
|
expect(getAuthorBadge({ address: 'plebeius.bso', role: 'owner' })).toEqual({
|
||
|
|
icon: 'admin',
|
||
|
|
label: '5chan Dev',
|
||
|
|
title: '5chan Dev',
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
it('keeps board role labels for non-developers', () => {
|
||
|
|
expect(getAuthorBadge({ address: 'other.bso', role: 'moderator' })).toEqual({
|
||
|
|
capitalizeLabel: true,
|
||
|
|
icon: 'mod',
|
||
|
|
label: 'Board mod',
|
||
|
|
title: 'moderator_of_this_board',
|
||
|
|
});
|
||
|
|
expect(getAuthorBadge({ address: 'other.bso', role: 'owner' })).toEqual({
|
||
|
|
capitalizeLabel: true,
|
||
|
|
icon: 'admin',
|
||
|
|
label: 'Board owner',
|
||
|
|
title: 'administrator_of_this_board',
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|