This repository has been archived by the owner on Sep 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #1564 PiperOrigin-RevId: 208489962
- Loading branch information
1 parent
a66dbe2
commit 9b31c4f
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
_tests/test/regression/1540_reset_deferred_query_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters