2018-08-31 23:38:22 +02:00
|
|
|
import {DecToBinConverter} from './dec-to-bin-converter';
|
|
|
|
|
|
|
|
describe('DecToBinConverter', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
let sut: DecToBinConverter;
|
|
|
|
|
|
|
|
beforeEach(() => sut = new DecToBinConverter());
|
|
|
|
|
2018-08-31 23:38:22 +02:00
|
|
|
it('should create an instance', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
expect(sut).toBeTruthy();
|
2018-08-31 23:38:22 +02:00
|
|
|
});
|
2018-09-01 00:34:41 +02:00
|
|
|
|
2018-08-31 23:40:47 +02:00
|
|
|
it('should have the id "dectobin"', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
expect(sut.getId()).toEqual('dectobin');
|
2018-08-31 23:38:22 +02:00
|
|
|
});
|
2018-09-01 00:34:41 +02:00
|
|
|
|
2018-08-31 23:38:22 +02:00
|
|
|
it('should convert "22" to "10110"', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
expect(sut.convert('22')).toEqual('10110');
|
2018-08-31 23:38:22 +02:00
|
|
|
});
|
2018-09-01 00:34:41 +02:00
|
|
|
|
2018-08-31 23:38:22 +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:38:22 +02:00
|
|
|
});
|
|
|
|
});
|