@@ -4,6 +4,7 @@ import { ActivatedRoute, RouterModule } from '@angular/router';
4
4
import { ngtx } from '../../ngtx' ;
5
5
import { ScenarioTestingHarness } from '../../scenario-testing/scenario-harnesses' ;
6
6
import { useScenarioTesting } from '../../scenario-testing/scenario-testing' ;
7
+ import { NgtxScenarioTestAssertionFn } from '../../scenario-testing/types' ;
7
8
8
9
@Injectable ( )
9
10
class MyService {
@@ -57,7 +58,11 @@ const withServiceState = <T>(token: Type<T>, state: Partial<T>) =>
57
58
// Usage Example
58
59
// ----------------------------
59
60
60
- const { scenario, expect, tests } = useScenarioTesting ( {
61
+ const {
62
+ scenario,
63
+ expect : expectThat ,
64
+ tests,
65
+ } = useScenarioTesting ( {
61
66
componentType : ScenarioTestComponent ,
62
67
moduleConfig : {
63
68
imports : [ RouterModule . forRoot ( [ ] ) ] ,
@@ -110,16 +115,31 @@ scenario(`The param id is 42`)
110
115
the . ParamIdDiv . toHaveAttributes ( { title : 42 } ) ,
111
116
) ;
112
117
113
- expect (
118
+ expectThat (
114
119
the . Div . toBeFound ( ) ,
115
120
the . ParamIdDiv . toBeMissing ( ) ,
116
121
the . Text . toHaveState ( { text : 'Hello, World!' } ) ,
117
122
) ;
118
123
119
- expect (
124
+ const beComponentType =
125
+ ( type : any ) : NgtxScenarioTestAssertionFn < HTMLElement , any > =>
126
+ // TODO: docs: document that debugElement must only be accessed within it case:
127
+ ( addTests , harness ) =>
128
+ addTests ( ( ) => {
129
+ it ( `should be the component "${ type . name } "` , ( ) => {
130
+ expect ( harness . debugElement . componentInstance ) . toBeInstanceOf ( type ) ;
131
+ } ) ;
132
+ } ) ;
133
+
134
+ expectThat (
120
135
the . Div . toBeFound ( ) ,
121
136
the . ParamIdDiv . toBeMissing ( ) ,
122
137
the . Text . toHaveState ( { text : 'Hello, World!' } ) ,
138
+ the . Text . to (
139
+ beComponentType ( TextComponent ) ,
140
+ beComponentType ( TextComponent ) ,
141
+ beComponentType ( TextComponent ) ,
142
+ ) ,
123
143
) ;
124
144
125
145
tests . run ( ) ;
0 commit comments