Sifa professional network frontend (Next.js, React, TailwindCSS) sifa.id/
at main 28 lines 1.1 kB view raw
1import { describe, it, expect } from 'vitest'; 2import { resolveDisplayFollowers } from '@/lib/follower-utils'; 3 4describe('resolveDisplayFollowers', () => { 5 it('prefers atprotoFollowersCount when positive', () => { 6 expect(resolveDisplayFollowers(5000, 10)).toEqual({ count: 5000, source: 'atproto' }); 7 }); 8 9 it('falls back to followersCount when atproto is zero', () => { 10 expect(resolveDisplayFollowers(0, 42)).toEqual({ count: 42, source: 'sifa' }); 11 }); 12 13 it('falls back to followersCount when atproto is null', () => { 14 expect(resolveDisplayFollowers(null, 42)).toEqual({ count: 42, source: 'sifa' }); 15 }); 16 17 it('falls back to followersCount when atproto is undefined', () => { 18 expect(resolveDisplayFollowers(undefined, 42)).toEqual({ count: 42, source: 'sifa' }); 19 }); 20 21 it('returns undefined when both are zero', () => { 22 expect(resolveDisplayFollowers(0, 0)).toBeUndefined(); 23 }); 24 25 it('returns undefined when both are absent', () => { 26 expect(resolveDisplayFollowers(undefined, undefined)).toBeUndefined(); 27 }); 28});