UNPKG

br-gender

Version:

Package to determine gender by name. Some database doest not have GENDER intel, so it can be very helpful a lib that can predict gender based on a person's first name. Be aware, this lib was built upon Brazilians census. So it will work with Brazilian nam

36 lines (28 loc) 1.2 kB
import { getGenderByName } from './index'; beforeAll(() => { jest.setTimeout(30000); }) it('should return Female when name is Rebeca', async () => { const gender = await getGenderByName('Rebeca'); expect(gender).toBe('Female'); }); it('should return Male when name is Thiago', async () => { const gender = await getGenderByName('Thiago'); expect(gender).toBe('Male'); }); it('should return NA when name is pretty hard to define by census', async () => { const gender = await getGenderByName('asdfg'); expect(gender).toBe('NA'); }); it('should have property percentage when pass to method -> percentage: true', async () => { const gender = await getGenderByName('Rebeca', { percentage: true }); expect(gender).toHaveProperty('percentage'); }); it('should have property percentage when pass to method -> percentage: true', async () => { const gender = await getGenderByName('Thiago', { percentage: true }); expect(gender).toHaveProperty('percentage'); }); it('should return NA when name is pretty hard to define by census with percentage', async () => { const gender = await getGenderByName('asdfg', { percentage: true }); expect(gender).toHaveProperty('percentage'); });