| 
									
										
										
										
											2016-06-23 09:47:54 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-26 15:54:34 -07:00
										 |  |  | import {escapeIdentifier} from '@angular/compiler/src/output/abstract_emitter'; | 
					
						
							| 
									
										
										
										
											2016-09-27 17:12:25 -07:00
										 |  |  | import {describe, expect, it} from '@angular/core/testing/testing_internal'; | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('AbstractEmitter', () => { | 
					
						
							| 
									
										
										
										
											2016-08-26 15:54:34 -07:00
										 |  |  |     describe('escapeIdentifier', () => { | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |       it('should escape single quotes', | 
					
						
							| 
									
										
										
										
											2016-08-26 15:54:34 -07:00
										 |  |  |          () => { expect(escapeIdentifier(`'`, false)).toEqual(`'\\''`); }); | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       it('should escape backslash', | 
					
						
							| 
									
										
										
										
											2016-08-26 15:54:34 -07:00
										 |  |  |          () => { expect(escapeIdentifier('\\', false)).toEqual(`'\\\\'`); }); | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       it('should escape newlines', | 
					
						
							| 
									
										
										
										
											2016-08-26 15:54:34 -07:00
										 |  |  |          () => { expect(escapeIdentifier('\n', false)).toEqual(`'\\n'`); }); | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       it('should escape carriage returns', | 
					
						
							| 
									
										
										
										
											2016-08-26 15:54:34 -07:00
										 |  |  |          () => { expect(escapeIdentifier('\r', false)).toEqual(`'\\r'`); }); | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-26 15:54:34 -07:00
										 |  |  |       it('should escape $', () => { expect(escapeIdentifier('$', true)).toEqual(`'\\$'`); }); | 
					
						
							|  |  |  |       it('should not escape $', () => { expect(escapeIdentifier('$', false)).toEqual(`'$'`); }); | 
					
						
							|  |  |  |       it('should add quotes for non-identifiers', | 
					
						
							|  |  |  |          () => { expect(escapeIdentifier('==', false, false)).toEqual(`'=='`); }); | 
					
						
							|  |  |  |       it('does not escape class (but it probably should)', | 
					
						
							|  |  |  |          () => { expect(escapeIdentifier('class', false, false)).toEqual('class'); }); | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } |