@@ -6,14 +6,14 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
66import { FormsModule } from '@angular/forms' ;
77import { of } from 'rxjs' ;
88
9- import { AdminTeamsComponent } from './admin-teams .component' ;
9+ import { TeamDashboardComponent } from './team-dashboard .component' ;
1010import { TeamsService } from '../teams-service' ;
1111import { Team } from '../team' ;
12- import { AdminTeamCreateComponent } from '../admin -team-create/admin -team-create .component' ;
12+ import { CreateTeamDialogComponent } from '../create -team/create -team.component' ;
1313
14- describe ( 'AdminTeamsComponent ', ( ) => {
15- let component : AdminTeamsComponent ;
16- let fixture : ComponentFixture < AdminTeamsComponent > ;
14+ fdescribe ( 'TeamDashboardComponent ', ( ) => {
15+ let component : TeamDashboardComponent ;
16+ let fixture : ComponentFixture < TeamDashboardComponent > ;
1717 let mockTeamsService : jasmine . SpyObj < TeamsService > ;
1818 let mockDialog : jasmine . SpyObj < MatDialog > ;
1919
@@ -33,7 +33,7 @@ describe('AdminTeamsComponent', () => {
3333 const dialogSpy = jasmine . createSpyObj ( 'MatDialog' , [ 'open' ] ) ;
3434
3535 await TestBed . configureTestingModule ( {
36- declarations : [ AdminTeamsComponent ] ,
36+ declarations : [ TeamDashboardComponent ] ,
3737 imports : [
3838 MatTableModule ,
3939 MatPaginatorModule ,
@@ -46,19 +46,17 @@ describe('AdminTeamsComponent', () => {
4646 ]
4747 } ) . compileComponents ( ) ;
4848
49- fixture = TestBed . createComponent ( AdminTeamsComponent ) ;
49+ fixture = TestBed . createComponent ( TeamDashboardComponent ) ;
5050 component = fixture . componentInstance ;
5151 mockTeamsService = TestBed . inject ( TeamsService ) as jasmine . SpyObj < TeamsService > ;
5252 mockDialog = TestBed . inject ( MatDialog ) as jasmine . SpyObj < MatDialog > ;
5353
5454 mockTeamsService . getTeams . and . returnValue ( of ( mockTeamsResponse ) ) ;
55+ mockTeamsService . getTeams . calls . reset ( ) ;
5556 } ) ;
5657
5758 it ( 'should create' , ( ) => {
5859 expect ( component ) . toBeTruthy ( ) ;
59- } ) ;
60-
61- it ( 'should initialize with correct default values' , ( ) => {
6260 expect ( component . teamSearch ) . toBe ( '' ) ;
6361 expect ( component . pageSize ) . toBe ( 10 ) ;
6462 expect ( component . pageIndex ) . toBe ( 0 ) ;
@@ -81,11 +79,14 @@ describe('AdminTeamsComponent', () => {
8179
8280 it ( 'should perform search with debouncing' , fakeAsync ( ( ) => {
8381 fixture . detectChanges ( ) ;
84- mockTeamsService . getTeams . calls . reset ( ) ;
85-
8682 component . search ( 'test' ) ;
8783 tick ( 100 ) ; // Less than debounce time
88- expect ( mockTeamsService . getTeams ) . not . toHaveBeenCalled ( ) ;
84+ expect ( mockTeamsService . getTeams ) . not . toHaveBeenCalledWith ( {
85+ term : 'test' ,
86+ sort : { name : 1 } ,
87+ limit : 10 ,
88+ start : '0'
89+ } ) ;
8990
9091 tick ( 200 ) ; // Complete debounce time (250ms total)
9192 expect ( mockTeamsService . getTeams ) . toHaveBeenCalledWith ( {
@@ -107,9 +108,6 @@ describe('AdminTeamsComponent', () => {
107108 } ) ) ;
108109
109110 it ( 'should handle page changes' , ( ) => {
110- fixture . detectChanges ( ) ;
111- mockTeamsService . getTeams . calls . reset ( ) ;
112-
113111 const pageEvent : PageEvent = {
114112 pageIndex : 1 ,
115113 pageSize : 25 ,
@@ -131,8 +129,6 @@ describe('AdminTeamsComponent', () => {
131129 it ( 'should reset search and pagination' , ( ) => {
132130 component . teamSearch = 'test' ;
133131 component . pageIndex = 2 ;
134- fixture . detectChanges ( ) ;
135- mockTeamsService . getTeams . calls . reset ( ) ;
136132
137133 component . reset ( ) ;
138134
@@ -153,32 +149,28 @@ describe('AdminTeamsComponent', () => {
153149
154150 component . newTeam ( ) ;
155151
156- expect ( mockDialog . open ) . toHaveBeenCalledWith ( AdminTeamCreateComponent , {
152+ expect ( mockDialog . open ) . toHaveBeenCalledWith ( CreateTeamDialogComponent , {
157153 width : '50rem' ,
158154 height : '25rem' ,
159155 data : { team : { } }
160156 } ) ;
161157 } ) ;
162158
163159 it ( 'should refresh teams after creating new team' , ( ) => {
164- fixture . detectChanges ( ) ;
165160 const newTeam = { id : '4' , name : 'New Team' , description : 'New team description' } ;
166161 const dialogRefSpy = jasmine . createSpyObj ( 'MatDialogRef' , [ 'afterClosed' ] ) ;
167162 dialogRefSpy . afterClosed . and . returnValue ( of ( newTeam ) ) ;
168163 mockDialog . open . and . returnValue ( dialogRefSpy ) ;
169- mockTeamsService . getTeams . calls . reset ( ) ;
170164
171165 component . newTeam ( ) ;
172166
173167 expect ( mockTeamsService . getTeams ) . toHaveBeenCalled ( ) ;
174168 } ) ;
175169
176170 it ( 'should not refresh teams if dialog is cancelled' , ( ) => {
177- fixture . detectChanges ( ) ;
178171 const dialogRefSpy = jasmine . createSpyObj ( 'MatDialogRef' , [ 'afterClosed' ] ) ;
179172 dialogRefSpy . afterClosed . and . returnValue ( of ( null ) ) ;
180173 mockDialog . open . and . returnValue ( dialogRefSpy ) ;
181- mockTeamsService . getTeams . calls . reset ( ) ;
182174
183175 component . newTeam ( ) ;
184176
0 commit comments