Fix naming, add tests #5
					 6 changed files with 24 additions and 2 deletions
				
			
		|  | @ -1,6 +1,6 @@ | |||
| import {Base64Decoder} from './converter/base64-decoder'; | ||||
| import {Base64Encoder} from './converter/base64-encoder'; | ||||
| import {BinToDecConverter} from './converter/bintodecconverter'; | ||||
| import {BinToDecConverter} from './converter/bin-to-dec-converter'; | ||||
| import {Converter} from './converter/converter'; | ||||
| import {DecToBinConverter} from './converter/dectobinconverter'; | ||||
| import {DecToHexConverter} from './converter/dectohexconverter'; | ||||
|  |  | |||
|  | @ -10,4 +10,7 @@ describe('Base64Decoder', () => { | |||
|   it('should decode "SGVsbG8sIFdvcmxkIQ==" to "Hello, World!"', () => { | ||||
|     expect(new Base64Decoder().convert('SGVsbG8sIFdvcmxkIQ==')).toEqual('Hello, World!'); | ||||
|   }); | ||||
|   it('should raise an exception on invalid input', () => { | ||||
|     expect(() => new Base64Decoder().convert('foo bar.')).toThrowError('Could not decode base64 string. Maybe corrupt input?'); | ||||
|   }); | ||||
| }); | ||||
|  |  | |||
|  | @ -10,4 +10,7 @@ describe('Base64Encoder', () => { | |||
|   it('should encode "Oh, guete Tag!" to "T2gsIGd1ZXRlIFRhZyE="', () => { | ||||
|     expect(new Base64Encoder().convert('Oh, guete Tag!')).toEqual('T2gsIGd1ZXRlIFRhZyE='); | ||||
|   }); | ||||
|   it('should raise an exception on invalid input', () => { | ||||
|     expect(() => new Base64Encoder().convert('€')).toThrowError(/Looks like you've got a character outside of the Latin1 range there./); | ||||
|   }); | ||||
| }); | ||||
|  |  | |||
|  | @ -14,7 +14,7 @@ export class Base64Encoder implements Converter { | |||
|       return btoa(input); | ||||
|     } catch (exception) { | ||||
|       console.error(exception); | ||||
|       throw new Error('Ouch! Looks like you\'ve got a UTF-8 character there. Too bad, this is not supported yet. ' | ||||
|       throw new Error('Ouch! Looks like you\'ve got a character outside of the Latin1 range there. Too bad, this is not supported yet. ' | ||||
|         + 'We\'re working on it and hope to be ready soon! Why don\'t you ' | ||||
|         + '<a href="https://duckduckgo.com/?q=cute+kitties&iar=images">enjoy some kittens</a> meanwhile?'); | ||||
|     } | ||||
|  |  | |||
							
								
								
									
										16
									
								
								src/app/converter/bin-to-dec-converter.spec.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/app/converter/bin-to-dec-converter.spec.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | |||
| import {BinToDecConverter} from './bin-to-dec-converter'; | ||||
| 
 | ||||
| describe('BinToDecConverter', () => { | ||||
|   it('should create an instance', () => { | ||||
|     expect(new BinToDecConverter()).toBeTruthy(); | ||||
|   }); | ||||
|   it('should have the id "base64encode"', () => { | ||||
|     expect(new BinToDecConverter().getId()).toEqual('bintodec'); | ||||
|   }); | ||||
|   it('should convert "11011" to "27"', () => { | ||||
|     expect(new BinToDecConverter().convert('11011')).toEqual('27'); | ||||
|   }); | ||||
|   it('should raise an exception on invalid input', () => { | ||||
|     expect(() => new BinToDecConverter().convert('foo bar')).toThrowError('The input seems not to be a valid binary number.'); | ||||
|   }); | ||||
| }); | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue