diff --git a/src/app/converter-registry.service.ts b/src/app/converter-registry.service.ts index a4721c6..d6f6714 100644 --- a/src/app/converter-registry.service.ts +++ b/src/app/converter-registry.service.ts @@ -13,7 +13,7 @@ import {PunycodeDecoder} from './converter/punycode-decoder'; import {PunycodeEncoder} from './converter/punycode-encoder'; import {QuotedPrintableDecoder} from './converter/quoted-printable-decoder'; import {QuotedPrintableEncoder} from './converter/quoted-printable-encoder'; -import {ROT13Converter} from './converter/rot13converter'; +import {ROT13Converter} from './converter/rot13-converter'; import {URIComponentDecoder} from './converter/uricomponentdecoder'; import {URIComponentEncoder} from './converter/uricomponentencoder'; import {URIDecoder} from './converter/uridecoder'; diff --git a/src/app/converter/rot13-converter.spec.ts b/src/app/converter/rot13-converter.spec.ts new file mode 100644 index 0000000..76e472d --- /dev/null +++ b/src/app/converter/rot13-converter.spec.ts @@ -0,0 +1,24 @@ +import {ROT13Converter} from './rot13-converter'; + +describe('ROT13Converter', () => { + let sut: ROT13Converter; + + beforeEach(() => sut = new ROT13Converter()); + + it('should create an instance', () => { + expect(sut).toBeTruthy(); + }); + + it('should have the id "rot13"', () => { + expect(sut.getId()).toEqual('rot13'); + }); + + it('should encode "Hello, World!" to "Uryyb, Jbeyq!"', () => { + expect(sut.convert('Hello, World!')).toEqual('Uryyb, Jbeyq!'); + }); + + it('should return the original input after being applied twice', () => { + const input = 'Ok, so this string is just a bunch of letters. And numbers: 1, 2, 3. Ans others: /&%. Kthxbye!'; + expect(sut.convert(sut.convert(input))).toEqual(input); + }); +}); diff --git a/src/app/converter/rot13converter.ts b/src/app/converter/rot13-converter.ts similarity index 96% rename from src/app/converter/rot13converter.ts rename to src/app/converter/rot13-converter.ts index ed51b5d..0bc9df5 100644 --- a/src/app/converter/rot13converter.ts +++ b/src/app/converter/rot13-converter.ts @@ -6,7 +6,7 @@ export class ROT13Converter implements Converter { } getId(): string { - return 'rot13convert'; + return 'rot13'; } convert(input: string): string {