Fix naming, add tests #5
					 5 changed files with 56 additions and 2 deletions
				
			
		|  | @ -9,8 +9,8 @@ import {HTMLEntitiesDecoder} from './converter/htmlentities-decoder'; | |||
| import {HTMLEntitiesEncoder} from './converter/htmlentities-encoder'; | ||||
| import {Injectable} from '@angular/core'; | ||||
| import {NativeLibraryWrapperService} from './native-library-wrapper.service'; | ||||
| import {PunycodeDecoder} from './converter/punycodedecoder'; | ||||
| import {PunycodeEncoder} from './converter/punycodeencoder'; | ||||
| import {PunycodeDecoder} from './converter/punycode-decoder'; | ||||
| import {PunycodeEncoder} from './converter/punycode-encoder'; | ||||
| import {QuotedPrintableDecoder} from './converter/quotedprintabledecoder'; | ||||
| import {QuotedPrintableEncoder} from './converter/quotedprintableencoder'; | ||||
| import {ROT13Converter} from './converter/rot13converter'; | ||||
|  |  | |||
							
								
								
									
										27
									
								
								src/app/converter/punycode-decoder.spec.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/app/converter/punycode-decoder.spec.ts
									
										
									
									
									
										Normal 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); | ||||
|   }); | ||||
| }); | ||||
							
								
								
									
										27
									
								
								src/app/converter/punycode-encoder.spec.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/app/converter/punycode-encoder.spec.ts
									
										
									
									
									
										Normal 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); | ||||
|   }); | ||||
| }); | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue