feat(transform): update for Directive.host

This commit is contained in:
Victor Berchet
2015-06-09 12:54:47 +02:00
committed by Tobias Bosch
parent 20953ed492
commit 591f742d42
12 changed files with 45 additions and 52 deletions

View File

@ -75,15 +75,28 @@ void allTests() {
expect(metadata.exportAs).toEqual('exportAsName');
});
it('should parse host listeners.', () async {
it('should parse host.', () async {
var metadata = await readMetadata('directive_metadata_extractor/'
'directive_metadata_files/host_listeners.ng_deps.dart');
expect(metadata.hostListeners).toBeNotNull();
expect(metadata.hostListeners.length).toBe(2);
expect(metadata.hostListeners.length).toBe(1);
expect(metadata.hostListeners).toContain('change');
expect(metadata.hostListeners['change']).toEqual('onChange(\$event)');
expect(metadata.hostListeners).toContain('keyDown');
expect(metadata.hostListeners['keyDown']).toEqual('onKeyDown(\$event)');
expect(metadata.hostProperties).toBeNotNull();
expect(metadata.hostProperties.length).toBe(1);
expect(metadata.hostProperties).toContain('value');
expect(metadata.hostProperties['value']).toEqual('value');
expect(metadata.hostAttributes).toBeNotNull();
expect(metadata.hostAttributes.length).toBe(1);
expect(metadata.hostAttributes).toContain('attName');
expect(metadata.hostAttributes['attName']).toEqual('attValue');
expect(metadata.hostActions).toBeNotNull();
expect(metadata.hostActions.length).toBe(1);
expect(metadata.hostActions).toContain('actionName');
expect(metadata.hostActions['actionName']).toEqual('actionValue');
});
it('should parse lifecycle events.', () async {

View File

@ -14,9 +14,11 @@ void initReflector(reflector) {
'parameters': const [const []],
'annotations': const [
const Component(
hostListeners: const {
'change': 'onChange(\$event)',
'keyDown': 'onKeyDown(\$event)'
host: const {
'(change)': 'onChange(\$event)',
'[value]': 'value',
'@actionName': 'actionValue',
'attName': 'attValue'
})
]
});

View File

@ -3,10 +3,10 @@
"id": "MyComponent",
"selector": "[soup]",
"compileChildren": true,
"hostListeners": {},
"hostProperties": {},
"hostListeners": {},
"hostActions": {},
"hostAttributes": {},
"hostActions": null,
"properties": [],
"readAttributes": [],
"type": 1,

View File

@ -4,8 +4,7 @@
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"host":{},
"properties":[],
"readAttributes":[],
"type":1,

View File

@ -4,8 +4,7 @@
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"host":{},
"properties":[],
"readAttributes":[],
"type":1,

View File

@ -4,8 +4,7 @@
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"host":{},
"properties":[],
"readAttributes":[],
"type":1,

View File

@ -4,8 +4,7 @@
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"host":{},
"properties":[],
"readAttributes":[],
"type":1,
@ -15,8 +14,7 @@
"id":"GoodbyeCmp",
"selector":"goodbye-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"host":{},
"properties":[],
"readAttributes":[],
"type":1,

View File

@ -4,8 +4,7 @@
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"host":{},
"properties":[],
"readAttributes":[],
"type":1,

View File

@ -4,8 +4,7 @@
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"host":{},
"properties":[],
"readAttributes":[],
"type":1,

View File

@ -3,8 +3,7 @@
"id":"GoodbyeCmp",
"selector":"goodbye-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"host":{},
"properties":[],
"readAttributes":[],
"type":1,

View File

@ -4,8 +4,7 @@
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"host":{},
"properties":[],
"readAttributes":[],
"type":1,