Fixed QuotedPrintable{De,En}coder file names and added tests.
This commit is contained in:
parent
bdf15d277e
commit
0a6a397e29
5 changed files with 68 additions and 2 deletions
|
@ -11,8 +11,8 @@ import {Injectable} from '@angular/core';
|
||||||
import {NativeLibraryWrapperService} from './native-library-wrapper.service';
|
import {NativeLibraryWrapperService} from './native-library-wrapper.service';
|
||||||
import {PunycodeDecoder} from './converter/punycode-decoder';
|
import {PunycodeDecoder} from './converter/punycode-decoder';
|
||||||
import {PunycodeEncoder} from './converter/punycode-encoder';
|
import {PunycodeEncoder} from './converter/punycode-encoder';
|
||||||
import {QuotedPrintableDecoder} from './converter/quotedprintabledecoder';
|
import {QuotedPrintableDecoder} from './converter/quoted-printable-decoder';
|
||||||
import {QuotedPrintableEncoder} from './converter/quotedprintableencoder';
|
import {QuotedPrintableEncoder} from './converter/quoted-printable-encoder';
|
||||||
import {ROT13Converter} from './converter/rot13converter';
|
import {ROT13Converter} from './converter/rot13converter';
|
||||||
import {URIComponentDecoder} from './converter/uricomponentdecoder';
|
import {URIComponentDecoder} from './converter/uricomponentdecoder';
|
||||||
import {URIComponentEncoder} from './converter/uricomponentencoder';
|
import {URIComponentEncoder} from './converter/uricomponentencoder';
|
||||||
|
|
33
src/app/converter/quoted-printable-decoder.spec.ts
Normal file
33
src/app/converter/quoted-printable-decoder.spec.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import {NativeLibraryWrapperService} from '../native-library-wrapper.service';
|
||||||
|
import {QuotedPrintableDecoder} from './quoted-printable-decoder';
|
||||||
|
import createSpyObj = jasmine.createSpyObj;
|
||||||
|
import Spy = jasmine.Spy;
|
||||||
|
|
||||||
|
describe('QuotedPrintableDecoder', () => {
|
||||||
|
let sut: QuotedPrintableDecoder;
|
||||||
|
let nativeWrapperSpy: Partial<NativeLibraryWrapperService>;
|
||||||
|
let decodeSpy: Spy;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
nativeWrapperSpy = {quotedPrintable: createSpyObj(['decode'])};
|
||||||
|
decodeSpy = nativeWrapperSpy.quotedPrintable.decode as Spy;
|
||||||
|
sut = new QuotedPrintableDecoder((nativeWrapperSpy as NativeLibraryWrapperService));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create an instance', () => {
|
||||||
|
expect(sut).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have the id "decodequotedprintable"', () => {
|
||||||
|
expect(sut.getId()).toEqual('decodequotedprintable');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call through to the native quoted printable decoder', () => {
|
||||||
|
const testInput = 'My input';
|
||||||
|
const expectedOutput = 'It worked';
|
||||||
|
decodeSpy.and.returnValue(expectedOutput);
|
||||||
|
const result: string = sut.convert(testInput);
|
||||||
|
expect(result).toEqual(expectedOutput);
|
||||||
|
expect(decodeSpy).toHaveBeenCalledWith(testInput);
|
||||||
|
});
|
||||||
|
});
|
33
src/app/converter/quoted-printable-encoder.spec.ts
Normal file
33
src/app/converter/quoted-printable-encoder.spec.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import {NativeLibraryWrapperService} from '../native-library-wrapper.service';
|
||||||
|
import {QuotedPrintableEncoder} from './quoted-printable-encoder';
|
||||||
|
import createSpyObj = jasmine.createSpyObj;
|
||||||
|
import Spy = jasmine.Spy;
|
||||||
|
|
||||||
|
describe('QuotedPrintableEncoder', () => {
|
||||||
|
let sut: QuotedPrintableEncoder;
|
||||||
|
let nativeWrapperSpy: Partial<NativeLibraryWrapperService>;
|
||||||
|
let encodeSpy: Spy;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
nativeWrapperSpy = {quotedPrintable: createSpyObj(['encode'])};
|
||||||
|
encodeSpy = nativeWrapperSpy.quotedPrintable.encode as Spy;
|
||||||
|
sut = new QuotedPrintableEncoder(nativeWrapperSpy as NativeLibraryWrapperService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create an instance', () => {
|
||||||
|
expect(sut).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have the id "encodequotedprintable"', () => {
|
||||||
|
expect(sut.getId()).toEqual('encodequotedprintable');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call through to the native quoted printable encoder', () => {
|
||||||
|
const testInput = 'My input';
|
||||||
|
const expectedOutput = 'It worked';
|
||||||
|
encodeSpy.and.returnValue(expectedOutput);
|
||||||
|
const result: string = sut.convert(testInput);
|
||||||
|
expect(result).toEqual(expectedOutput);
|
||||||
|
expect(encodeSpy).toHaveBeenCalledWith(testInput);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue