forked from angulardart/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Test): Add a test for angulardart#1540.
- Loading branch information
1 parent
47f948a
commit b328544
Showing
1 changed file
with
46 additions
and
0 deletions.
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 {} |