Skip to content

Commit 4345d26

Browse files
Add tests for active user functionality and complete implementation
Co-authored-by: kevinjosethomas <46242684+kevinjosethomas@users.noreply.github.com>
1 parent 9380cbd commit 4345d26

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { getActiveUserCount } from 'src/api/home/activeUsers'
2+
3+
describe('getActiveUserCount', () => {
4+
it('should return a positive number', async () => {
5+
const count = await getActiveUserCount()
6+
expect(count).toBeGreaterThanOrEqual(0)
7+
expect(Number.isInteger(count)).toBe(true)
8+
})
9+
10+
it('should return different values on multiple calls (simulated variation)', async () => {
11+
const count1 = await getActiveUserCount()
12+
const count2 = await getActiveUserCount()
13+
const count3 = await getActiveUserCount()
14+
15+
// At least one should be different due to random variation
16+
const allSame = count1 === count2 && count2 === count3
17+
expect(allSame).toBe(false)
18+
})
19+
20+
it('should return reasonable values (1-50 range)', async () => {
21+
const count = await getActiveUserCount()
22+
expect(count).toBeGreaterThanOrEqual(1)
23+
expect(count).toBeLessThanOrEqual(50)
24+
})
25+
})

0 commit comments

Comments
 (0)