Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
chore(Test): Add a test for #1540.
Browse files Browse the repository at this point in the history
Closes #1564

PiperOrigin-RevId: 208489962
  • Loading branch information
matanlurey committed Aug 13, 2018
1 parent a66dbe2 commit 9b31c4f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
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 {}
5 changes: 4 additions & 1 deletion angular/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@
```
... additionally, a check for a race condition of the deferred component
being loaded _after_ the parent view was already destroyed was added.
being loaded _after_ the parent view was already destroyed was added. As
a result, [#1540][] has also been fixed (view and content queries were not
getting reset as the `@deferred` node was destroyed).
[#1538]: https://github.com/dart-lang/angular/issues/1538
[#1539]: https://github.com/dart-lang/angular/issues/1539
[#1540]: https://github.com/dart-lang/angular/issues/1540
[#1558]: https://github.com/dart-lang/angular/issues/1558
## 5.0.0
Expand Down

0 comments on commit 9b31c4f

Please sign in to comment.