varna / measure-ts

Format length or area units to human readable Strings.
MIT License
5 stars 1 forks source link

Add method to get UnitKey #13

Closed svycka closed 5 years ago

varna commented 5 years ago
describe('unitKey', () => {
  test('m', () => {
    const measure = new Measure(1, 'm')
    expect(measure.unitKey).toBe('m')
  })
  test('cm', () => {
    const measure = new Measure(1, 'cm')
    expect(measure.unitKey).toBe('cm')
  })
  test('m2', () => {
    const measure = new Measure(1, 'm2')
    expect(measure.unitKey).toBe('m2')
  })
  test('cm3', () => {
    const measure = new Measure(1, 'cm3')
    expect(measure.unitKey).toBe('cm3')
  })
})

describe('extension', () => {
  test('m', () => {
    const measure = new Measure(1, 'm')
    expect(measure.extension).toBe('m')
  })
  test('cm', () => {
    const measure = new Measure(1, 'cm')
    expect(measure.extension).toBe('cm')
  })
  test('m2', () => {
    const measure = new Measure(1, 'm2')
    expect(measure.extension).toBe('m²')
  })
  test('cm3', () => {
    const measure = new Measure(1, 'cm3')
    expect(measure.extension).toBe('cm³')
  })
})