11// Import the necessary action creators and constants from the respective files
2- import { teamMembersFectchACtion , userTeamsUpdateAction , addNewTeam , teamsDeleteAction , updateTeamAction , teamUsersFetchAction , teamUsersFetchCompleteAction , teamUsersFetchErrorAction , teamMemberDeleteAction , teamMemberAddAction , updateVisibilityAction , fetchAllTeamCodeSucess , fetchAllTeamCodeFailure , getAllUserTeams , postNewTeam , deleteTeam } from '../allTeamsAction' ;
3- import { RECEIVE_ALL_USER_TEAMS , USER_TEAMS_UPDATE , ADD_NEW_TEAM , TEAMS_DELETE , UPDATE_TEAM , FETCH_TEAM_USERS_START , RECEIVE_TEAM_USERS , FETCH_TEAM_USERS_ERROR , TEAM_MEMBER_DELETE , TEAM_MEMBER_ADD , UPDATE_TEAM_MEMBER_VISIBILITY , FETCH_ALL_TEAM_CODE_SUCCESS , FETCH_ALL_TEAM_CODE_FAILURE } from '../../constants/allTeamsConstants' ;
42import configureMockStore from 'redux-mock-store' ;
53import thunk from 'redux-thunk' ;
64import axios from 'axios' ;
75import MockAdapter from 'axios-mock-adapter' ;
6+ import {
7+ RECEIVE_ALL_USER_TEAMS ,
8+ USER_TEAMS_UPDATE ,
9+ ADD_NEW_TEAM ,
10+ TEAMS_DELETE ,
11+ UPDATE_TEAM ,
12+ FETCH_TEAM_USERS_START ,
13+ RECEIVE_TEAM_USERS ,
14+ FETCH_TEAM_USERS_ERROR ,
15+ TEAM_MEMBER_DELETE ,
16+ TEAM_MEMBER_ADD ,
17+ UPDATE_TEAM_MEMBER_VISIBILITY ,
18+ FETCH_ALL_TEAM_CODE_SUCCESS ,
19+ } from '../../constants/allTeamsConstants' ;
20+ import {
21+ teamMembersFectchACtion ,
22+ userTeamsUpdateAction ,
23+ addNewTeam ,
24+ teamsDeleteAction ,
25+ updateTeamAction ,
26+ teamUsersFetchAction ,
27+ teamUsersFetchCompleteAction ,
28+ teamUsersFetchErrorAction ,
29+ teamMemberDeleteAction ,
30+ teamMemberAddAction ,
31+ updateVisibilityAction ,
32+ fetchAllTeamCodeSucess ,
33+ getAllUserTeams ,
34+ postNewTeam ,
35+ deleteTeam ,
36+ } from '../allTeamsAction' ;
837import { ENDPOINTS } from '../../utils/URL' ;
938
1039const middlewares = [ thunk ] ;
@@ -16,7 +45,10 @@ describe('teamMembersFectchACtion', () => {
1645 // Test case for creating an action to set all user teams
1746 it ( 'should create an action to set all user teams' , ( ) => {
1847 // Define the payload for the action
19- const payload = [ { id : 1 , name : 'Team 1' } , { id : 2 , name : 'Team 2' } ] ;
48+ const payload = [
49+ { id : 1 , name : 'Team 1' } ,
50+ { id : 2 , name : 'Team 2' } ,
51+ ] ;
2052 // Define the expected action object
2153 const expectedAction = {
2254 type : RECEIVE_ALL_USER_TEAMS ,
@@ -109,7 +141,10 @@ describe('teamUsersFetchAction', () => {
109141// Describe block for the teamUsersFetchCompleteAction tests
110142describe ( 'teamUsersFetchCompleteAction' , ( ) => {
111143 it ( 'should create an action to set team users' , ( ) => {
112- const payload = [ { id : 1 , name : 'User 1' } , { id : 2 , name : 'User 2' } ] ;
144+ const payload = [
145+ { id : 1 , name : 'User 1' } ,
146+ { id : 2 , name : 'User 2' } ,
147+ ] ;
113148 const expectedAction = {
114149 type : RECEIVE_TEAM_USERS ,
115150 payload,
@@ -198,18 +233,18 @@ describe('fetchAllTeamCodeSucess', () => {
198233 } ) ;
199234} ) ;
200235
201-
202236// Describe block for the getAllUserTeams tests
203237describe ( 'getAllUserTeams' , ( ) => {
204238 // Test case for fetching all user teams
205239 it ( 'should fetch all user teams and dispatch RECEIVE_ALL_USER_TEAMS action' , async ( ) => {
206240 // Mock the API response
207- const responseData = [ { id : 1 , name : 'Team 1' } , { id : 2 , name : 'Team 2' } ] ;
241+ const responseData = [
242+ { id : 1 , name : 'Team 1' } ,
243+ { id : 2 , name : 'Team 2' } ,
244+ ] ;
208245 mock . onGet ( ENDPOINTS . TEAM ) . reply ( 200 , responseData ) ;
209246
210- const expectedActions = [
211- { type : RECEIVE_ALL_USER_TEAMS , payload : responseData } ,
212- ] ;
247+ const expectedActions = [ { type : RECEIVE_ALL_USER_TEAMS , payload : responseData } ] ;
213248
214249 const store = mockStore ( { } ) ;
215250 await store . dispatch ( getAllUserTeams ( ) ) ;
@@ -225,9 +260,7 @@ describe('postNewTeam', () => {
225260 const responseData = { id : 3 , name : 'New Team' } ;
226261 mock . onPost ( ENDPOINTS . TEAM ) . reply ( 200 , responseData ) ;
227262
228- const expectedActions = [
229- { type : ADD_NEW_TEAM , payload : responseData , status : true } ,
230- ] ;
263+ const expectedActions = [ { type : ADD_NEW_TEAM , payload : responseData , status : true } ] ;
231264
232265 const store = mockStore ( { } ) ;
233266 await store . dispatch ( postNewTeam ( 'New Team' , true ) ) ;
@@ -243,13 +276,10 @@ describe('deleteTeam', () => {
243276 const teamId = 1 ;
244277 mock . onDelete ( ENDPOINTS . TEAM_DATA ( teamId ) ) . reply ( 200 ) ;
245278
246- const expectedActions = [
247- { type : TEAMS_DELETE , team : teamId } ,
248- ] ;
279+ const expectedActions = [ { type : TEAMS_DELETE , team : teamId } ] ;
249280
250281 const store = mockStore ( { } ) ;
251282 await store . dispatch ( deleteTeam ( teamId ) ) ;
252283 expect ( store . getActions ( ) ) . toEqual ( expectedActions ) ;
253284 } ) ;
254285} ) ;
255-
0 commit comments