28 lines
726 B
TypeScript
28 lines
726 B
TypeScript
import {DecToBinConverter} from './dec-to-bin-converter';
|
|
|
|
describe('DecToBinConverter', () => {
|
|
let sut: DecToBinConverter;
|
|
|
|
beforeEach(() => sut = new DecToBinConverter());
|
|
|
|
it('should create an instance', () => {
|
|
expect(sut).toBeTruthy();
|
|
});
|
|
|
|
it('should have a display name', () => {
|
|
expect(sut.getDisplayname()).toBeTruthy();
|
|
});
|
|
|
|
it('should have the id "dectobin"', () => {
|
|
expect(sut.getId()).toEqual('dectobin');
|
|
});
|
|
|
|
it('should convert "22" to "10110"', () => {
|
|
expect(sut.convert('22')).toEqual('10110');
|
|
});
|
|
|
|
it('should raise an exception on invalid input', () => {
|
|
expect(() => sut.convert('foo bar')).toThrowError('The input seems not to be a valid integer.');
|
|
});
|
|
});
|