fabasoad/business-card

View on GitHub
src/__tests__/scripts/DigitConverter.spec.ts

Summary

Maintainability
A
0 mins
Test Coverage
import DigitConverter from '../../scripts/DigitConverter'

describe('DigitConverter', () => {
  type DigitConverterFixture = {
    convert: (c: DigitConverter) => string
    expected: string
    title: string
  }

  test.each([{
    convert: (c: DigitConverter) => c.toSingleByte('2019'),
    expected: '2019',
    title: 'single'
  }, {
    convert: (c: DigitConverter) => c.toDoubleByte('2019'),
    expected: '2019',
    title: 'double'
  }])('should convert to $title byte correctly', (f: DigitConverterFixture) =>
    expect(f.convert(new DigitConverter())).toBe(f.expected)
  )
})