converter/src/app/converter/base64-encoder.spec.ts

28 lines
787 B
TypeScript

import {Base64Encoder} from './base64-encoder';
describe('Base64Encoder', () => {
let sut: Base64Encoder;
beforeEach(() => sut = new Base64Encoder());
it('should create an instance', () => {
expect(sut).toBeTruthy();
});
it('should have a display name', () => {
expect(sut.getDisplayname()).toBeTruthy();
});
it('should have the id "base64encode"', () => {
expect(sut.getId()).toEqual('base64encode');
});
it('should encode "Oh, guete Tag!" to "T2gsIGd1ZXRlIFRhZyE="', () => {
expect(sut.convert('Oh, guete Tag!')).toEqual('T2gsIGd1ZXRlIFRhZyE=');
});
it('should raise an exception on invalid input', () => {
expect(() => sut.convert('€')).toThrowError(/Looks like you've got a character outside of the Latin1 range there./);
});
});