From d1dde13befcb4d460013f1b413716d8081fa7d7d Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Sat, 1 Sep 2018 00:58:41 +0200 Subject: [PATCH] Added tests for URI{De,En}coder. --- src/app/converter/uridecoder.spec.ts | 21 +++++++++++++++++++++ src/app/converter/uriencoder.spec.ts | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/app/converter/uridecoder.spec.ts create mode 100644 src/app/converter/uriencoder.spec.ts diff --git a/src/app/converter/uridecoder.spec.ts b/src/app/converter/uridecoder.spec.ts new file mode 100644 index 0000000..7e45297 --- /dev/null +++ b/src/app/converter/uridecoder.spec.ts @@ -0,0 +1,21 @@ +import {URIDecoder} from './uridecoder'; + +describe('URIDecoder', () => { + let sut: URIDecoder; + + beforeEach(() => sut = new URIDecoder()); + + it('should create an instance', () => { + expect(sut).toBeTruthy(); + }); + + it('should have the id "uridecode"', () => { + expect(sut.getId()).toEqual('uridecode'); + }); + + it('should decode "http://m%C3%A4nu:gh%C3%ABim@host:port/hi.there?oh=well#ya" ' + + 'to "http://mänu:ghëim@host:port/hi.there?oh=well#ya"', () => { + expect(sut.convert('http://m%C3%A4nu:gh%C3%ABim@host:port/hi.there?oh=well#ya')) + .toEqual('http://mänu:ghëim@host:port/hi.there?oh=well#ya'); + }); +}); diff --git a/src/app/converter/uriencoder.spec.ts b/src/app/converter/uriencoder.spec.ts new file mode 100644 index 0000000..52f0a20 --- /dev/null +++ b/src/app/converter/uriencoder.spec.ts @@ -0,0 +1,21 @@ +import {URIEncoder} from './uriencoder'; + +describe('URIEncoder', () => { + let sut: URIEncoder; + + beforeEach(() => sut = new URIEncoder()); + + it('should create an instance', () => { + expect(sut).toBeTruthy(); + }); + + it('should have the id "uriencode"', () => { + expect(sut.getId()).toEqual('uriencode'); + }); + + it('should encode "http://mänu:ghëim@host:port/hi.there?oh=well#ya" ' + + 'to "http://m%C3%A4nu:gh%C3%ABim@host:port/hi.there?oh=well#ya"', () => { + expect(sut.convert('http://mänu:ghëim@host:port/hi.there?oh=well#ya')) + .toEqual('http://m%C3%A4nu:gh%C3%ABim@host:port/hi.there?oh=well#ya'); + }); +});