| 
									
										
										
										
											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-09-27 17:12:25 -07:00
										 |  |  | import {describe, expect, it} from '@angular/core/testing/testing_internal'; | 
					
						
							| 
									
										
										
										
											2016-05-27 20:15:40 -07:00
										 |  |  | import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 16:38:52 -07:00
										 |  |  | import {parseCookieValue} from '../../src/browser/browser_adapter'; | 
					
						
							| 
									
										
										
										
											2016-05-27 20:15:40 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('cookies', () => { | 
					
						
							|  |  |  |     it('parses cookies', () => { | 
					
						
							| 
									
										
										
										
											2016-11-12 14:08:58 +01:00
										 |  |  |       const cookie = 'other-cookie=false; xsrf-token=token-value; is_awesome=true; ffo=true;'; | 
					
						
							| 
									
										
										
										
											2016-05-27 20:15:40 -07:00
										 |  |  |       expect(parseCookieValue(cookie, 'xsrf-token')).toBe('token-value'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     it('handles encoded keys', () => { | 
					
						
							|  |  |  |       expect(parseCookieValue('whitespace%20token=token-value', 'whitespace token')) | 
					
						
							|  |  |  |           .toBe('token-value'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     it('handles encoded values', () => { | 
					
						
							|  |  |  |       expect(parseCookieValue('token=whitespace%20', 'token')).toBe('whitespace '); | 
					
						
							|  |  |  |       expect(parseCookieValue('token=whitespace%0A', 'token')).toBe('whitespace\n'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     it('sets cookie values', () => { | 
					
						
							|  |  |  |       getDOM().setCookie('my test cookie', 'my test value'); | 
					
						
							|  |  |  |       getDOM().setCookie('my other cookie', 'my test value 2'); | 
					
						
							|  |  |  |       expect(getDOM().getCookie('my test cookie')).toBe('my test value'); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } |