Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 9295a92

Browse files
committed
test(compiler): asserts that bindings are not called on missing attrs.
1 parent 9da6d2e commit 9295a92

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

test/core_dom/compiler_spec.dart

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ void main() {
5656
..bind(Parent, toValue: null)
5757
..bind(Child)
5858
..bind(ChildTemplateComponent)
59-
..bind(InjectorDependentComponent)
60-
..bind(TranscludeChildrenWithAttributeDirective);
59+
..bind(TranscludeChildrenWithAttributeDirective)
60+
..bind(LoggedBinding)
61+
..bind(InjectorDependentComponent);
6162
});
6263

6364
beforeEach((TestBed tb) => _ = tb);
@@ -187,6 +188,13 @@ void main() {
187188
expect(log).toEqual(['OneOfTwo', 'TwoOfTwo']);
188189
});
189190

191+
it('should not call bindings that are not present', async((Logger log) {
192+
var element = _.compile('<log-bind></log-bind>');
193+
_.rootScope.apply();
194+
expect(log.length).toEqual(0);
195+
}));
196+
197+
190198
it('should compile a directive that ignores children', (Logger log) {
191199
// The ng-repeat comes first, so it is not ignored, but the children *are*
192200
var element = _.compile('<div ng-repeat="i in [1,2]" ignore-children><div two-directives></div></div>');
@@ -298,6 +306,7 @@ void main() {
298306
..bind(ConditionalContentComponent)
299307
..bind(ExprAttrComponent)
300308
..bind(LogElementComponent)
309+
..bind(LoggedBinding)
301310
..bind(SayHelloFormatter)
302311
..bind(OuterComponent)
303312
..bind(InnerComponent)
@@ -729,7 +738,6 @@ void main() {
729738
component.expr = 'angular';
730739
_.rootScope.apply();
731740
expect(_.rootScope.context['name']).toEqual('angular');
732-
733741
expect(_.rootScope.context['done']).toEqual(false);
734742
component.onDone();
735743
expect(_.rootScope.context['done']).toEqual(true);
@@ -1716,3 +1724,17 @@ class InnerInnerComponent {
17161724
)
17171725
class TemplateUrlComponent {
17181726
}
1727+
1728+
@Component(
1729+
selector: 'log-bind',
1730+
map: const {
1731+
'optional-one': '=>optional',
1732+
'optional-two': '<=>optional',
1733+
'optional-once': '=>!optional',
1734+
}
1735+
)
1736+
class LoggedBinding {
1737+
Logger logger;
1738+
LoggedBinding(this.logger);
1739+
set optional(input) => logger(input);
1740+
}

0 commit comments

Comments
 (0)