2018-08-31 23:40:47 +02:00
|
|
|
import {DecToHexConverter} from './dec-to-hex-converter';
|
|
|
|
|
|
|
|
describe('DecToHexConverter', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
let sut: DecToHexConverter;
|
|
|
|
|
|
|
|
beforeEach(() => sut = new DecToHexConverter());
|
|
|
|
|
2018-08-31 23:40:47 +02:00
|
|
|
it('should create an instance', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
expect(sut).toBeTruthy();
|
2018-08-31 23:40:47 +02:00
|
|
|
});
|
2018-09-01 00:34:41 +02:00
|
|
|
|
2018-08-31 23:40:47 +02:00
|
|
|
it('should have the id "dectohex"', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
expect(sut.getId()).toEqual('dectohex');
|
2018-08-31 23:40:47 +02:00
|
|
|
});
|
2018-09-01 00:34:41 +02:00
|
|
|
|
2018-08-31 23:40:47 +02:00
|
|
|
it('should convert "22" to "16"', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
expect(sut.convert('22')).toEqual('16');
|
2018-08-31 23:40:47 +02:00
|
|
|
});
|
2018-09-01 00:34:41 +02:00
|
|
|
|
2018-08-31 23:40:47 +02:00
|
|
|
it('should raise an exception on invalid input', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
expect(() => sut.convert('foo bar')).toThrowError('The input seems not to be a valid integer.');
|
2018-08-31 23:40:47 +02:00
|
|
|
});
|
|
|
|
});
|