feature/upgrade #12

Merged
manuel merged 67 commits from feature/upgrade into master 2024-01-28 00:13:54 +01:00
5 changed files with 56 additions and 2 deletions
Showing only changes of commit 5841195cda - Show all commits

View file

@ -9,8 +9,8 @@ import {HTMLEntitiesDecoder} from './converter/htmlentities-decoder';
import {HTMLEntitiesEncoder} from './converter/htmlentities-encoder'; import {HTMLEntitiesEncoder} from './converter/htmlentities-encoder';
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {NativeLibraryWrapperService} from './native-library-wrapper.service'; import {NativeLibraryWrapperService} from './native-library-wrapper.service';
import {PunycodeDecoder} from './converter/punycodedecoder'; import {PunycodeDecoder} from './converter/punycode-decoder';
import {PunycodeEncoder} from './converter/punycodeencoder'; import {PunycodeEncoder} from './converter/punycode-encoder';
import {QuotedPrintableDecoder} from './converter/quotedprintabledecoder'; import {QuotedPrintableDecoder} from './converter/quotedprintabledecoder';
import {QuotedPrintableEncoder} from './converter/quotedprintableencoder'; import {QuotedPrintableEncoder} from './converter/quotedprintableencoder';
import {ROT13Converter} from './converter/rot13converter'; import {ROT13Converter} from './converter/rot13converter';

View file

@ -0,0 +1,27 @@
import {PunycodeDecoder} from './punycode-decoder';
import {NativeLibraryWrapperService} from '../native-library-wrapper.service';
import createSpyObj = jasmine.createSpyObj;
import Spy = jasmine.Spy;
describe('PunycodeDecoder', () => {
let nativeWrapperSpy: Partial<NativeLibraryWrapperService>;
let decodeSpy: Spy;
beforeEach(() => {
nativeWrapperSpy = {punycode: createSpyObj(['decode'])};
decodeSpy = nativeWrapperSpy.punycode.decode as Spy;
});
it('should create an instance', () => {
expect(new PunycodeDecoder(nativeWrapperSpy as NativeLibraryWrapperService)).toBeTruthy();
});
it('should have the id "decodepunycode"', () => {
expect(new PunycodeDecoder(nativeWrapperSpy as NativeLibraryWrapperService).getId()).toEqual('decodepunycode');
});
it('should call through to the native punycode decoder', () => {
const testInput = 'My input';
const expectedOutput = 'It worked';
decodeSpy.and.returnValue(expectedOutput);
const result: string = new PunycodeDecoder(nativeWrapperSpy as NativeLibraryWrapperService).convert(testInput);
expect(result).toEqual(expectedOutput);
expect(decodeSpy).toHaveBeenCalledWith(testInput);
});
});

View file

@ -0,0 +1,27 @@
import {NativeLibraryWrapperService} from '../native-library-wrapper.service';
import {PunycodeEncoder} from './punycode-encoder';
import createSpyObj = jasmine.createSpyObj;
import Spy = jasmine.Spy;
describe('PunycodeEncoder', () => {
let nativeWrapperSpy: Partial<NativeLibraryWrapperService>;
let encodeSpy: Spy;
beforeEach(() => {
nativeWrapperSpy = {punycode: createSpyObj(['encode'])};
encodeSpy = nativeWrapperSpy.punycode.encode as Spy;
});
it('should create an instance', () => {
expect(new PunycodeEncoder(nativeWrapperSpy as NativeLibraryWrapperService)).toBeTruthy();
});
it('should have the id "encodepunycode"', () => {
expect(new PunycodeEncoder(nativeWrapperSpy as NativeLibraryWrapperService).getId()).toEqual('encodepunycode');
});
it('should call through to the native punycode encoder', () => {
const testInput = 'My input';
const expectedOutput = 'It worked';
encodeSpy.and.returnValue(expectedOutput);
const result: string = new PunycodeEncoder(nativeWrapperSpy as NativeLibraryWrapperService).convert(testInput);
expect(result).toEqual(expectedOutput);
expect(encodeSpy).toHaveBeenCalledWith(testInput);
});
});