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

17 lines
630 B
TypeScript

import {BinToDecConverter} from './bin-to-dec-converter';
describe('BinToDecConverter', () => {
it('should create an instance', () => {
expect(new BinToDecConverter()).toBeTruthy();
});
it('should have the id "bintodec"', () => {
expect(new BinToDecConverter().getId()).toEqual('bintodec');
});
it('should convert "11011" to "27"', () => {
expect(new BinToDecConverter().convert('11011')).toEqual('27');
});
it('should raise an exception on invalid input', () => {
expect(() => new BinToDecConverter().convert('1foo bar')).toThrowError('The input seems not to be a valid binary number.');
});
});