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

Commit 1633521

Browse files
mvuksanojbdeboer
authored andcommitted
test: Add more tests related to types exposed from a component.
Closes #885 Closes #958
1 parent e607aeb commit 1633521

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

test/core_dom/compiler_spec.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,13 @@ void main() {
553553
toBe(PublishModuleAttrDirective._injector.get(PublishModuleDirectiveSuperType));
554554
});
555555

556+
it('should expose PublishModuleDirectiveSuperType as PublishModuleDirectiveSuperType', () {
557+
_.compile(r'<div publish-types probe="publishModuleProbe"></div>');
558+
var probe = _.rootScope.context['publishModuleProbe'];
559+
var directive = probe.injector.get(PublishModuleDirectiveSuperType);
560+
expect(directive is PublishModuleAttrDirective).toBeTruthy();
561+
});
562+
556563
it('should allow repeaters over controllers', async((Logger logger) {
557564
_.compile(r'<log ng-repeat="i in [1, 2]"></log>');
558565
_.rootScope.apply();

test/directive/ng_form_spec.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ void main() {
143143
expect(form).toBeValid();
144144
});
145145

146+
it('should expose NgForm as NgControl', (Scope scope, TestBed _) {
147+
_.compile('<form name="myForm" probe="formProbe"><input type="text" /></form>');
148+
scope.apply();
149+
150+
expect(scope.context['formProbe'].injector.get(NgControl) is NgForm).toBeTruthy();
151+
});
152+
146153
it('should add and remove the correct flags when set to valid and to invalid',
147154
(Scope scope, TestBed _) {
148155

test/routing/ng_bind_route_spec.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ main() {
4343
.toEqual('all');
4444
}));
4545

46+
it('should expose NgBindRoute as RouteProvider', async(() {
47+
Element root = _.compile(
48+
'<div ng-bind-route="library"><div probe="routeProbe"></div></div>');
49+
expect(_.rootScope.context['routeProbe'].injector.get(RouteProvider) is NgBindRoute).toBeTruthy();
50+
}));
51+
4652
});
4753
}
4854

test/routing/ng_view_spec.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ main() {
2121
router = _router;
2222

2323
templates.put('foo.html', new HttpResponse(200,
24-
'<h1>Foo</h1>'));
24+
'<h1 probe="p">Foo</h1>'));
2525
templates.put('bar.html', new HttpResponse(200,
26-
'<h1>Bar</h1>'));
26+
'<h1 probe="p">Bar</h1>'));
2727
});
2828

2929

@@ -47,6 +47,15 @@ main() {
4747
expect(root.text).toEqual('Foo');
4848
}));
4949

50+
it('should expose NgView as RouteProvider', async(() {
51+
_.compile('<ng-view probe="m"></ng-view>');
52+
router.route('/foo');
53+
microLeap();
54+
_.rootScope.apply();
55+
56+
expect(_.rootScope.context['p'].injector.get(RouteProvider) is NgView).toBeTruthy();
57+
}));
58+
5059

5160
it('should switch template when route is already active', async(() {
5261
// Force the routing system to initialize.

0 commit comments

Comments
 (0)