File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
apps/example-app/src/app/examples Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Component } from '@angular/core' ;
12import { render , screen } from '@testing-library/angular' ;
23import userEvent from '@testing-library/user-event' ;
34
45import { SpoilerDirective } from './08-directive' ;
56
7+ test ( 'it is possible to test directives with container component' , async ( ) => {
8+ @Component ( {
9+ template : `<div appSpoiler data-testid="dir"></div>` ,
10+ imports : [ SpoilerDirective ] ,
11+ standalone : true ,
12+ } )
13+ class FixtureComponent { }
14+
15+ const user = userEvent . setup ( ) ;
16+ await render ( FixtureComponent ) ;
17+
18+ const directive = screen . getByTestId ( 'dir' ) ;
19+
20+ expect ( screen . queryByText ( 'I am visible now...' ) ) . not . toBeInTheDocument ( ) ;
21+ expect ( screen . getByText ( 'SPOILER' ) ) . toBeInTheDocument ( ) ;
22+
23+ await user . hover ( directive ) ;
24+ expect ( screen . queryByText ( 'SPOILER' ) ) . not . toBeInTheDocument ( ) ;
25+ expect ( screen . getByText ( 'I am visible now...' ) ) . toBeInTheDocument ( ) ;
26+
27+ await user . unhover ( directive ) ;
28+ expect ( screen . getByText ( 'SPOILER' ) ) . toBeInTheDocument ( ) ;
29+ expect ( screen . queryByText ( 'I am visible now...' ) ) . not . toBeInTheDocument ( ) ;
30+ } ) ;
31+
632test ( 'it is possible to test directives' , async ( ) => {
733 const user = userEvent . setup ( ) ;
834
You can’t perform that action at this time.
0 commit comments