FrontendAtlas
Study
▾
Dashboard
Pricing
Get full access
</> Code
Test cases
Language
JavaScript
TypeScript
export default function validateUsername(name) { throw new Error('Not implemented'); }
import validateUsername from './validateUsername'; describe('validateUsername', () => { test('accepts valid usernames', () => { expect(validateUsername('alice_1')).toBe(true); expect(validateUsername('abc')).toBe(true); expect(validateUsername('a123456789012345')).toBe(true); }); test('rejects invalid length', () => { expect(validateUsername('ab')).toBe(false); expect(validateUsername('a1234567890123456')).toBe(false); }); test('rejects uppercase or invalid chars', () => { expect(validateUsername('Alice')).toBe(false); expect(validateUsername('bob-dash')).toBe(false); }); test('rejects leading digit, trailing underscore, or consecutive underscores', () => { expect(validateUsername('2cool')).toBe(false); expect(validateUsername('bob_')).toBe(false); expect(validateUsername('bob__x')).toBe(false); }); });
▶ Run tests
Results
Console
Run tests to see results.