| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  | import { | 
					
						
							|  |  |  |   ddescribe, | 
					
						
							|  |  |  |   describe, | 
					
						
							|  |  |  |   it, | 
					
						
							|  |  |  |   iit, | 
					
						
							|  |  |  |   xit, | 
					
						
							|  |  |  |   expect, | 
					
						
							|  |  |  |   beforeEach, | 
					
						
							|  |  |  |   afterEach, | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | } from '@angular/core/testing/testing_internal'; | 
					
						
							|  |  |  | import {browserDetection} from '@angular/platform-browser/testing'; | 
					
						
							| 
									
										
										
										
											2015-07-04 22:25:43 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | import {DecimalPipe, PercentPipe, CurrencyPipe} from '@angular/common'; | 
					
						
							| 
									
										
										
										
											2015-07-04 22:25:43 +04:30
										 |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |   describe('Number pipes', () => { | 
					
						
							|  |  |  |     // TODO(mlaval): enable tests when Intl API is no longer used, see
 | 
					
						
							|  |  |  |     // https://github.com/angular/angular/issues/3333
 | 
					
						
							|  |  |  |     if (browserDetection.supportsIntlApi) { | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |       describe("DecimalPipe", () => { | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |         var pipe; | 
					
						
							| 
									
										
										
										
											2015-07-04 22:25:43 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |         beforeEach(() => { pipe = new DecimalPipe(); }); | 
					
						
							| 
									
										
										
										
											2015-07-04 22:25:43 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |         describe("transform", () => { | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |           it('should return correct value for numbers', () => { | 
					
						
							| 
									
										
										
										
											2016-04-22 15:33:32 -07:00
										 |  |  |             expect(pipe.transform(12345)).toEqual('12,345'); | 
					
						
							|  |  |  |             expect(pipe.transform(123, '.2')).toEqual('123.00'); | 
					
						
							|  |  |  |             expect(pipe.transform(1, '3.')).toEqual('001'); | 
					
						
							|  |  |  |             expect(pipe.transform(1.1, '3.4-5')).toEqual('001.1000'); | 
					
						
							| 
									
										
										
										
											2015-08-07 11:41:38 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-22 15:33:32 -07:00
										 |  |  |             expect(pipe.transform(1.123456, '3.4-5')).toEqual('001.12346'); | 
					
						
							|  |  |  |             expect(pipe.transform(1.1234)).toEqual('1.123'); | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |           }); | 
					
						
							| 
									
										
										
										
											2015-08-06 10:39:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |           it("should not support other objects", | 
					
						
							| 
									
										
										
										
											2016-04-22 15:33:32 -07:00
										 |  |  |              () => { expect(() => pipe.transform(new Object())).toThrowError(); }); | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2015-08-18 16:16:30 +02:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-07-04 22:25:43 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |       describe("PercentPipe", () => { | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |         var pipe; | 
					
						
							| 
									
										
										
										
											2015-07-04 22:25:43 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |         beforeEach(() => { pipe = new PercentPipe(); }); | 
					
						
							| 
									
										
										
										
											2015-07-04 22:25:43 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |         describe("transform", () => { | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |           it('should return correct value for numbers', () => { | 
					
						
							| 
									
										
										
										
											2016-04-22 15:33:32 -07:00
										 |  |  |             expect(pipe.transform(1.23)).toEqual('123%'); | 
					
						
							|  |  |  |             expect(pipe.transform(1.2, '.2')).toEqual('120.00%'); | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |           }); | 
					
						
							| 
									
										
										
										
											2015-08-06 10:39:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |           it("should not support other objects", | 
					
						
							| 
									
										
										
										
											2016-04-22 15:33:32 -07:00
										 |  |  |              () => { expect(() => pipe.transform(new Object())).toThrowError(); }); | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2015-08-18 16:16:30 +02:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-07-04 22:25:43 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |       describe("CurrencyPipe", () => { | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |         var pipe; | 
					
						
							| 
									
										
										
										
											2015-07-04 22:25:43 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |         beforeEach(() => { pipe = new CurrencyPipe(); }); | 
					
						
							| 
									
										
										
										
											2015-07-04 22:25:43 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |         describe("transform", () => { | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |           it('should return correct value for numbers', () => { | 
					
						
							| 
									
										
										
										
											2016-04-22 15:33:32 -07:00
										 |  |  |             expect(pipe.transform(123)).toEqual('USD123'); | 
					
						
							|  |  |  |             expect(pipe.transform(12, 'EUR', false, '.2')).toEqual('EUR12.00'); | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |           }); | 
					
						
							| 
									
										
										
										
											2015-08-06 10:39:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 09:40:37 -07:00
										 |  |  |           it("should not support other objects", | 
					
						
							| 
									
										
										
										
											2016-04-22 15:33:32 -07:00
										 |  |  |              () => { expect(() => pipe.transform(new Object())).toThrowError(); }); | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2015-08-18 16:16:30 +02:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2016-02-10 16:54:32 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2015-07-04 22:25:43 +04:30
										 |  |  | } |