Sha256: cb72e6eb0488648ed8a01b042a54bbd792bfd05da40d177f5ff3846290276baf

Contents?: true

Size: 1.91 KB

Versions: 71

Compression:

Stored size: 1.91 KB

Contents

import Say from './say'

describe('say', () => {
  const say = new Say()
  it('zero', () => {
    expect(say.inEnglish(0)).toBe('zero')
  })

  it('one', () => {
    expect(say.inEnglish(1)).toBe('one')
  })

  it('fourteen', () => {
    expect(say.inEnglish(14)).toBe('fourteen')
  })

  it('twenty', () => {
    expect(say.inEnglish(20)).toBe('twenty')
  })

  it('twenty-two', () => {
    expect(say.inEnglish(22)).toBe('twenty-two')
  })

  it('one hundred', () => {
    expect(say.inEnglish(100)).toBe('one hundred')
  })

  it('one hundred twenty-three', () => {
    expect(say.inEnglish(123)).toBe('one hundred twenty-three')
  })

  it('one thousand', () => {
    expect(say.inEnglish(1000)).toBe('one thousand')
  })

  it('one thousand two hundred thirty-four', () => {
    expect(say.inEnglish(1234)).toBe('one thousand two hundred thirty-four')
  })

  it('one million', () => {
    expect(say.inEnglish(1000000)).toBe('one million')
  })

  it('one million two', () => {
    expect(say.inEnglish(1000002)).toBe('one million two')
  })

  it('one million two thousand three hundred forty-five', () => {
    expect(say.inEnglish(1002345))
      .toBe('one million two thousand three hundred forty-five')
  })

  it('one billion', () => {
    expect(say.inEnglish(1000000000)).toBe('one billion')
  })

  it('a really big number', () => {
    let expected = 'nine hundred eighty-seven billion '
    expected += 'six hundred fifty-four million '
    expected += 'three hundred twenty-one thousand '
    expected += 'one hundred twenty-three'
    expect(say.inEnglish(987654321123)).toBe(expected)
  })

  it('raises an error below zero', () => {
    expect(() => {
      say.inEnglish(-1)
    }).toThrowError('Number must be between 0 and 999,999,999,999.')
  })

  it('raises an error above 999,999,999,999', () => {
    expect(() => {
      say.inEnglish(1000000000000)
    }).toThrowError('Number must be between 0 and 999,999,999,999.')
  })

})

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
trackler-2.1.0.16 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.15 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.14 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.13 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.12 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.11 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.10 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.9 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.8 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.7 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.6 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.5 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.4 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.3 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.2 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.1 tracks/typescript/exercises/say/say.test.ts
trackler-2.1.0.0 tracks/typescript/exercises/say/say.test.ts
trackler-2.0.8.55 tracks/typescript/exercises/say/say.test.ts
trackler-2.0.8.54 tracks/typescript/exercises/say/say.test.ts
trackler-2.0.8.53 tracks/typescript/exercises/say/say.test.ts