| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  | import {MapWrapper} from 'angular2/src/facade/collection'; | 
					
						
							|  |  |  | import {DirectiveMetadata} from 'angular2/src/render/api'; | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | import {directiveMetadataFromMap, directiveMetadataToMap} from 'angular2/src/render/dom/convert'; | 
					
						
							| 
									
										
										
										
											2015-05-11 12:31:16 -07:00
										 |  |  | import {ddescribe, describe, expect, it} from 'angular2/test_lib'; | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('convert', () => { | 
					
						
							|  |  |  |     it('directiveMetadataToMap', () => { | 
					
						
							|  |  |  |       var someComponent = new DirectiveMetadata({ | 
					
						
							|  |  |  |         compileChildren: false, | 
					
						
							|  |  |  |         hostListeners: MapWrapper.createFromPairs([['listenKey', 'listenVal']]), | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |         hostProperties: MapWrapper.createFromPairs([['hostPropKey', 'hostPropVal']]), | 
					
						
							|  |  |  |         hostActions: MapWrapper.createFromPairs([['hostActionKey', 'hostActionVal']]), | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  |         id: 'someComponent', | 
					
						
							| 
									
										
										
										
											2015-05-26 15:54:10 +02:00
										 |  |  |         properties: ['propKey: propVal'], | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  |         readAttributes: ['read1', 'read2'], | 
					
						
							|  |  |  |         selector: 'some-comp', | 
					
						
							|  |  |  |         type: DirectiveMetadata.COMPONENT_TYPE | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |       var map = directiveMetadataToMap(someComponent); | 
					
						
							|  |  |  |       expect(MapWrapper.get(map, 'compileChildren')).toEqual(false); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |       expect(MapWrapper.get(map, 'hostListeners')) | 
					
						
							|  |  |  |           .toEqual(MapWrapper.createFromPairs([['listenKey', 'listenVal']])); | 
					
						
							|  |  |  |       expect(MapWrapper.get(map, 'hostProperties')) | 
					
						
							|  |  |  |           .toEqual(MapWrapper.createFromPairs([['hostPropKey', 'hostPropVal']])); | 
					
						
							|  |  |  |       expect(MapWrapper.get(map, 'hostActions')) | 
					
						
							|  |  |  |           .toEqual(MapWrapper.createFromPairs([['hostActionKey', 'hostActionVal']])); | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  |       expect(MapWrapper.get(map, 'id')).toEqual('someComponent'); | 
					
						
							| 
									
										
										
										
											2015-05-26 15:54:10 +02:00
										 |  |  |       expect(MapWrapper.get(map, 'properties')).toEqual(['propKey: propVal']); | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  |       expect(MapWrapper.get(map, 'readAttributes')).toEqual(['read1', 'read2']); | 
					
						
							|  |  |  |       expect(MapWrapper.get(map, 'selector')).toEqual('some-comp'); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |       expect(MapWrapper.get(map, 'type')).toEqual(DirectiveMetadata.COMPONENT_TYPE); | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('mapToDirectiveMetadata', () => { | 
					
						
							|  |  |  |       var map = MapWrapper.createFromPairs([ | 
					
						
							|  |  |  |         ['compileChildren', false], | 
					
						
							|  |  |  |         ['hostListeners', MapWrapper.createFromPairs([['testKey', 'testVal']])], | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |         ['hostProperties', MapWrapper.createFromPairs([['hostPropKey', 'hostPropVal']])], | 
					
						
							|  |  |  |         ['hostActions', MapWrapper.createFromPairs([['hostActionKey', 'hostActionVal']])], | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  |         ['id', 'testId'], | 
					
						
							| 
									
										
										
										
											2015-05-26 15:54:10 +02:00
										 |  |  |         ['properties', ['propKey: propVal']], | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  |         ['readAttributes', ['readTest1', 'readTest2']], | 
					
						
							|  |  |  |         ['selector', 'testSelector'], | 
					
						
							| 
									
										
										
										
											2015-04-30 13:38:40 -07:00
										 |  |  |         ['type', DirectiveMetadata.DIRECTIVE_TYPE] | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  |       ]); | 
					
						
							|  |  |  |       var meta = directiveMetadataFromMap(map); | 
					
						
							|  |  |  |       expect(meta.compileChildren).toEqual(false); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |       expect(meta.hostListeners).toEqual(MapWrapper.createFromPairs([['testKey', 'testVal']])); | 
					
						
							|  |  |  |       expect(meta.hostProperties) | 
					
						
							|  |  |  |           .toEqual(MapWrapper.createFromPairs([['hostPropKey', 'hostPropVal']])); | 
					
						
							|  |  |  |       expect(meta.hostActions) | 
					
						
							|  |  |  |           .toEqual(MapWrapper.createFromPairs([['hostActionKey', 'hostActionVal']])); | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  |       expect(meta.id).toEqual('testId'); | 
					
						
							| 
									
										
										
										
											2015-05-26 15:54:10 +02:00
										 |  |  |       expect(meta.properties).toEqual(['propKey: propVal']); | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  |       expect(meta.readAttributes).toEqual(['readTest1', 'readTest2']); | 
					
						
							|  |  |  |       expect(meta.selector).toEqual('testSelector'); | 
					
						
							| 
									
										
										
										
											2015-04-30 13:38:40 -07:00
										 |  |  |       expect(meta.type).toEqual(DirectiveMetadata.DIRECTIVE_TYPE); | 
					
						
							| 
									
										
										
										
											2015-04-27 12:49:07 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } |