|
- import getNumberName from '../../../index';
-
- describe('Ordinals', () => {
- describe('0 in hundreds place', () => {
- describe('0 in tens place', () => {
- describe.each`
- ones | onesName
- ${0} | ${'zeroth'}
- ${1} | ${'first'}
- ${2} | ${'second'}
- ${3} | ${'third'}
- ${4} | ${'fourth'}
- ${5} | ${'fifth'}
- ${6} | ${'sixth'}
- ${7} | ${'seventh'}
- ${8} | ${'eighth'}
- ${9} | ${'ninth'}
- `('$ones in ones place', ({
- ones,
- onesName,
- }) => {
- it(`converts ${ones} to ${onesName}`, () => {
- expect(getNumberName(ones, {ordinal: true})).toBe(onesName);
- });
- });
- });
-
- describe('1 in tens place', () => {
- describe.each`
- ones | onesName
- ${0} | ${'tenth'}
- ${1} | ${'eleventh'}
- ${2} | ${'twelfth'}
- ${3} | ${'thirteenth'}
- ${4} | ${'fourteenth'}
- ${5} | ${'fifteenth'}
- ${6} | ${'sixteenth'}
- ${7} | ${'seventeenth'}
- ${8} | ${'eighteenth'}
- ${9} | ${'nineteenth'}
- `('$ones in ones place', ({
- ones,
- onesName,
- }) => {
- it(`converts 1${ones} to ${onesName}`, () => {
- expect(getNumberName(10 + ones, {ordinal: true})).toBe(onesName);
- });
- });
- });
-
- describe.each`
- tens | tensName
- ${2} | ${'twenty'}
- ${3} | ${'thirty'}
- ${4} | ${'forty'}
- ${5} | ${'fifty'}
- ${6} | ${'sixty'}
- ${7} | ${'seventy'}
- ${8} | ${'eighty'}
- ${9} | ${'ninety'}
- `('$tens in tens place', ({tens, tensName}) => {
- describe('0 in ones place', () => {
- const value = (tens * 10);
- const name = tensName.replace(/y$/, 'ieth');
-
- it(`converts ${value} to ${name}`, () => {
- expect(getNumberName(value, {ordinal: true})).toBe(name);
- });
- });
-
- describe.each`
- ones | onesName
- ${1} | ${'first'}
- ${2} | ${'second'}
- ${3} | ${'third'}
- ${4} | ${'fourth'}
- ${5} | ${'fifth'}
- ${6} | ${'sixth'}
- ${7} | ${'seventh'}
- ${8} | ${'eighth'}
- ${9} | ${'ninth'}
- `('$ones in ones place', ({
- ones,
- onesName,
- }) => {
- const value = (tens * 10) + ones;
- const name = [tensName, onesName].join(' ').trim();
-
- it(`converts ${value} to ${name}`, () => {
- expect(getNumberName(value, {ordinal: true})).toBe(name);
- });
- });
- });
- });
-
- describe.each`
- hundreds | hundredsName
- ${1} | ${'one hundred'}
- ${2} | ${'two hundred'}
- ${3} | ${'three hundred'}
- ${4} | ${'four hundred'}
- ${5} | ${'five hundred'}
- ${6} | ${'six hundred'}
- ${7} | ${'seven hundred'}
- ${8} | ${'eight hundred'}
- ${9} | ${'nine hundred'}
- `('$hundreds in hundreds place', ({
- hundreds,
- hundredsName,
- }) => {
- describe('0 in tens place', () => {
- describe('0 in ones place', () => {
- const value = (hundreds * 100);
- const name = hundredsName + 'th';
-
- it(`converts ${value} to ${name}`, () => {
- expect(getNumberName(value, {ordinal: true})).toBe(name);
- });
- });
-
- describe.each`
- ones | onesName
- ${1} | ${'first'}
- ${2} | ${'second'}
- ${3} | ${'third'}
- ${4} | ${'fourth'}
- ${5} | ${'fifth'}
- ${6} | ${'sixth'}
- ${7} | ${'seventh'}
- ${8} | ${'eighth'}
- ${9} | ${'ninth'}
- `('$ones in ones place', ({
- ones,
- onesName,
- }) => {
- const value = (hundreds * 100) + ones;
- const name = [hundredsName, onesName].join(' ').trim();
- it(`converts ${value} to ${name}`, () => {
- expect(getNumberName(value, {ordinal: true})).toBe(name);
- });
- });
- });
-
- describe('1 in tens place', () => {
- describe.each`
- ones | onesName
- ${0} | ${'tenth'}
- ${1} | ${'eleventh'}
- ${2} | ${'twelfth'}
- ${3} | ${'thirteenth'}
- ${4} | ${'fourteenth'}
- ${5} | ${'fifteenth'}
- ${6} | ${'sixteenth'}
- ${7} | ${'seventeenth'}
- ${8} | ${'eighteenth'}
- ${9} | ${'nineteenth'}
- `('$ones in ones place', ({
- ones,
- onesName,
- }) => {
- const value = (hundreds * 100) + 10 + ones;
- const name = [hundredsName, onesName].join(' ').trim();
- it(`converts ${value} to ${name}`, () => {
- expect(getNumberName(value, {ordinal: true})).toBe(name);
- });
- });
- });
-
- describe.each`
- tens | tensName
- ${2} | ${'twenty'}
- ${3} | ${'thirty'}
- ${4} | ${'forty'}
- ${5} | ${'fifty'}
- ${6} | ${'sixty'}
- ${7} | ${'seventy'}
- ${8} | ${'eighty'}
- ${9} | ${'ninety'}
- `('$tens in tens place', ({tens, tensName}) => {
- describe('0 in ones place', () => {
- const value = (hundreds * 100) + (tens * 10);
- const name = [hundredsName, tensName.replace(/y$/, 'ieth')].join(' ').trim();
-
- it(`converts ${value} to ${name}`, () => {
- expect(getNumberName(value, {ordinal: true})).toBe(name);
- });
- });
-
- describe.each`
- ones | onesName
- ${1} | ${'first'}
- ${2} | ${'second'}
- ${3} | ${'third'}
- ${4} | ${'fourth'}
- ${5} | ${'fifth'}
- ${6} | ${'sixth'}
- ${7} | ${'seventh'}
- ${8} | ${'eighth'}
- ${9} | ${'ninth'}
- `('$ones in ones place', ({
- ones,
- onesName,
- }) => {
- const value = (hundreds * 100) + (tens * 10) + ones;
- const name = [hundredsName, tensName, onesName].join(' ').trim();
-
- it(`converts ${value} to ${name}`, () => {
- expect(getNumberName(value, {ordinal: true})).toBe(name);
- });
- });
- });
- });
- });
|