Skip to content

Commit

Permalink
chore(Test): Add a test for angulardart#1540.
Browse files Browse the repository at this point in the history
  • Loading branch information
matanlurey committed Aug 12, 2018
1 parent 47f948a commit b328544
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions _tests/test/regression/1540_reset_deferred_query_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@TestOn('browser')
import 'package:angular/angular.dart';
import 'package:angular_test/angular_test.dart';
import 'package:test/test.dart';

import '1540_reset_deferred_query_test.template.dart' as ng;

void main() {
tearDown(disposeAnyRunningTest);

test('@deferred should work properly with queries', () async {
final fixture = await NgTestBed.forComponent(
ng.ViewChildTestNgFactory,
).create();
expect(fixture.assertOnlyInstance.child, isNull);
await fixture.update((c) => c.showChild = true);
expect(fixture.assertOnlyInstance.child, isNotNull);
await fixture.update((c) => c.showChild = false);
expect(fixture.assertOnlyInstance.child, isNull);
});
}

@Component(
selector: 'view-child-test',
directives: [
HelloWorldComponent,
NgIf,
],
template: r'''
<template [ngIf]="showChild">
<hello-world @deferred></hello-world>
</template>
''',
)
class ViewChildTest {
@ViewChild(HelloWorldComponent)
HelloWorldComponent child;

bool showChild = false;
}

@Component(
selector: 'hello-world',
template: 'Hello World',
)
class HelloWorldComponent {}

0 comments on commit b328544

Please sign in to comment.