converter/src/app/converter/hex-to-dec-converter.spec.ts

17 lines
630 B
TypeScript

import {HexToDecConverter} from './hex-to-dec-converter';
describe('HexToDecConverter', () => {
it('should create an instance', () => {
expect(new HexToDecConverter()).toBeTruthy();
});
it('should have the id "hextodec"', () => {
expect(new HexToDecConverter().getId()).toEqual('hextodec');
});
it('should convert "ab" to "171"', () => {
expect(new HexToDecConverter().convert('ab')).toEqual('171');
});
it('should raise an exception on invalid input', () => {
expect(() => new HexToDecConverter().convert('foo bar')).toThrowError('The input seems not to be a valid hexadecimal number.');
});
});