2018-08-31 23:22:15 +02:00
|
|
|
import {Base64Decoder} from './base64-decoder';
|
|
|
|
|
|
|
|
describe('Base64Decoder', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
let sut: Base64Decoder;
|
|
|
|
|
|
|
|
beforeEach(() => sut = new Base64Decoder());
|
|
|
|
|
2018-08-31 23:22:15 +02:00
|
|
|
it('should create an instance', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
expect(sut).toBeTruthy();
|
2018-08-31 23:22:15 +02:00
|
|
|
});
|
2018-09-01 00:34:41 +02:00
|
|
|
|
2018-09-01 01:20:41 +02:00
|
|
|
it('should have a display name', () => {
|
|
|
|
expect(sut.getDisplayname()).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
2018-08-31 23:22:15 +02:00
|
|
|
it('should have the id "base64decode"', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
expect(sut.getId()).toEqual('base64decode');
|
2018-08-31 23:22:15 +02:00
|
|
|
});
|
2018-09-01 00:34:41 +02:00
|
|
|
|
2018-08-31 23:22:15 +02:00
|
|
|
it('should decode "SGVsbG8sIFdvcmxkIQ==" to "Hello, World!"', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
expect(sut.convert('SGVsbG8sIFdvcmxkIQ==')).toEqual('Hello, World!');
|
2018-08-31 23:22:15 +02:00
|
|
|
});
|
2018-09-01 00:34:41 +02:00
|
|
|
|
2018-08-31 23:35:14 +02:00
|
|
|
it('should raise an exception on invalid input', () => {
|
2018-09-01 00:34:41 +02:00
|
|
|
expect(() => sut.convert('foo bar.')).toThrowError('Could not decode base64 string. Maybe corrupt input?');
|
2018-08-31 23:35:14 +02:00
|
|
|
});
|
2018-08-31 23:22:15 +02:00
|
|
|
});
|