@@ -22,7 +22,10 @@ describe("Organizations Team Endpoints", () => {
22
22
23
23
let userRepositoryFixture : UserRepositoryFixture ;
24
24
let organizationsRepositoryFixture : TeamRepositoryFixture ;
25
+ let teamsRepositoryFixture : TeamRepositoryFixture ;
26
+
25
27
let org : Team ;
28
+ let team : Team ;
26
29
27
30
const userEmail = "org-teams-controller-e2e@api.com" ;
28
31
let user : User ;
@@ -37,6 +40,7 @@ describe("Organizations Team Endpoints", () => {
37
40
38
41
userRepositoryFixture = new UserRepositoryFixture ( moduleRef ) ;
39
42
organizationsRepositoryFixture = new TeamRepositoryFixture ( moduleRef ) ;
43
+ teamsRepositoryFixture = new TeamRepositoryFixture ( moduleRef ) ;
40
44
41
45
user = await userRepositoryFixture . create ( {
42
46
email : userEmail ,
@@ -48,6 +52,12 @@ describe("Organizations Team Endpoints", () => {
48
52
isOrganization : true ,
49
53
} ) ;
50
54
55
+ team = await teamsRepositoryFixture . create ( {
56
+ name : "Test org team" ,
57
+ isOrganization : false ,
58
+ parent : { connect : { id : org . id } } ,
59
+ } ) ;
60
+
51
61
app = moduleRef . createNestApplication ( ) ;
52
62
bootstrap ( app as NestExpressApplication ) ;
53
63
@@ -72,6 +82,26 @@ describe("Organizations Team Endpoints", () => {
72
82
} ) ;
73
83
} ) ;
74
84
85
+ it ( "should fail if org does not exist" , async ( ) => {
86
+ return request ( app . getHttpServer ( ) ) . get ( `/v2/organizations/120494059/teams` ) . expect ( 403 ) ;
87
+ } ) ;
88
+
89
+ it ( "should get the team of the org" , async ( ) => {
90
+ return request ( app . getHttpServer ( ) )
91
+ . get ( `/v2/organizations/${ org . id } /teams/${ team . id } ` )
92
+ . expect ( 200 )
93
+ . then ( ( response ) => {
94
+ const responseBody : ApiSuccessResponse < Team > = response . body ;
95
+ expect ( responseBody . status ) . toEqual ( SUCCESS_STATUS ) ;
96
+ expect ( responseBody . data . id ) . toEqual ( team . id ) ;
97
+ expect ( responseBody . data . parentId ) . toEqual ( team . parentId ) ;
98
+ } ) ;
99
+ } ) ;
100
+
101
+ it ( "should fail if the team does not exist" , async ( ) => {
102
+ return request ( app . getHttpServer ( ) ) . get ( `/v2/organizations/${ org . id } /teams/123132145` ) . expect ( 403 ) ;
103
+ } ) ;
104
+
75
105
afterAll ( async ( ) => {
76
106
await userRepositoryFixture . deleteByEmail ( user . email ) ;
77
107
await organizationsRepositoryFixture . delete ( org . id ) ;
0 commit comments