@@ -25,23 +25,27 @@ const keys = [{ name: 'key', type: MenuI18nKey.Keys, route: ApplicationRoute.Key
25
25
describe ( 'Add Entities tab :: getEntitiesGridData' , ( ) => {
26
26
test ( 'Should return all items' , ( ) => {
27
27
expect (
28
- getEntitiesGridData (
29
- [ { name : 'model' } ] ,
30
- [ { name : 'application' } ] ,
31
- [ { name : 'role' } ] ,
32
- [ { name : 'key' } ] ,
33
- ) ,
28
+ getEntitiesGridData ( [ { name : 'model' } ] , [ { name : 'application' } ] , [ { name : 'role' } ] , [ { name : 'key' } ] ) ,
34
29
) . toEqual ( data ) ;
35
30
} ) ;
36
31
} ) ;
37
32
38
33
describe ( 'Add Entities tab :: getEntitiesForRole ' , ( ) => {
39
- test ( 'Should return empty array' , ( ) => {
34
+ test ( 'Should return empty array when no limits are defined ' , ( ) => {
40
35
expect ( getEntitiesForRole ( { } , data ) ) . toEqual ( [ ] ) ;
41
36
} ) ;
42
37
43
- test ( 'Should return array with model' , ( ) => {
44
- expect ( getEntitiesForRole ( { limits : { model : { day : 1 } } , model1 : { day : 1 } } , data ) ) . toEqual ( [
38
+ test ( 'Should return array with model and share properties when share is defined' , ( ) => {
39
+ expect (
40
+ getEntitiesForRole (
41
+ {
42
+ limits : { model : { day : 1 } } ,
43
+ share : { model : { invitationTtl : 3600 , maxAcceptedUsers : 10 } } ,
44
+ model1 : { day : 1 } ,
45
+ } ,
46
+ data ,
47
+ ) ,
48
+ ) . toEqual ( [
45
49
{
46
50
day : 1 ,
47
51
minute : 'No Limits' ,
@@ -50,14 +54,44 @@ describe('Add Entities tab :: getEntitiesForRole ', () => {
50
54
name : 'model' ,
51
55
route : ApplicationRoute . Models ,
52
56
type : MenuI18nKey . Models ,
57
+ invitationTtl : 3600 ,
58
+ maxAcceptedUsers : 10 ,
53
59
} ,
54
60
] ) ;
55
61
} ) ;
56
62
57
- test ( 'Should return array with model' , ( ) => {
63
+ test ( 'Should return array with model and updated limits and share properties' , ( ) => {
64
+ expect (
65
+ getEntitiesForRole (
66
+ {
67
+ limits : { model : { minute : 1 , week : 2 , month : 3 } } ,
68
+ share : { model : { invitationTtl : 1800 , maxAcceptedUsers : 5 } } ,
69
+ model1 : { minute : 1 , week : 2 , month : 3 } ,
70
+ } ,
71
+ data ,
72
+ ) ,
73
+ ) . toEqual ( [
74
+ {
75
+ day : 'No Limits' ,
76
+ minute : 1 ,
77
+ week : 2 ,
78
+ month : 3 ,
79
+ name : 'model' ,
80
+ route : ApplicationRoute . Models ,
81
+ type : MenuI18nKey . Models ,
82
+ invitationTtl : 1800 ,
83
+ maxAcceptedUsers : 5 ,
84
+ } ,
85
+ ] ) ;
86
+ } ) ;
87
+
88
+ test ( 'Should handle missing share properties and return "No Limits"' , ( ) => {
58
89
expect (
59
90
getEntitiesForRole (
60
- { limits : { model : { minute : 1 , week : 2 , month : 3 } } , model1 : { minute : 1 , week : 2 , month : 3 } } ,
91
+ {
92
+ limits : { model : { minute : 1 , week : 2 , month : 3 } } ,
93
+ model1 : { minute : 1 , week : 2 , month : 3 } ,
94
+ } ,
61
95
data ,
62
96
) ,
63
97
) . toEqual ( [
@@ -69,6 +103,92 @@ describe('Add Entities tab :: getEntitiesForRole ', () => {
69
103
name : 'model' ,
70
104
route : ApplicationRoute . Models ,
71
105
type : MenuI18nKey . Models ,
106
+ invitationTtl : 'No Limits' ,
107
+ maxAcceptedUsers : 'No Limits' ,
108
+ } ,
109
+ ] ) ;
110
+ } ) ;
111
+
112
+ test ( 'Should handle multiple entities with some missing share properties' , ( ) => {
113
+ expect (
114
+ getEntitiesForRole (
115
+ {
116
+ limits : {
117
+ model : { day : 1 } ,
118
+ model2 : { minute : 1 , week : 2 , month : 3 } ,
119
+ } ,
120
+ share : {
121
+ model : { invitationTtl : 3600 , maxAcceptedUsers : 10 } ,
122
+ } ,
123
+ model1 : { day : 1 } ,
124
+ } ,
125
+ data ,
126
+ ) ,
127
+ ) . toEqual ( [
128
+ {
129
+ day : 1 ,
130
+ minute : 'No Limits' ,
131
+ week : 'No Limits' ,
132
+ month : 'No Limits' ,
133
+ name : 'model' ,
134
+ route : ApplicationRoute . Models ,
135
+ type : MenuI18nKey . Models ,
136
+ invitationTtl : 3600 ,
137
+ maxAcceptedUsers : 10 ,
138
+ } ,
139
+ {
140
+ day : 'No Limits' ,
141
+ minute : 1 ,
142
+ week : 2 ,
143
+ month : 3 ,
144
+ invitationTtl : 'No Limits' ,
145
+ maxAcceptedUsers : 'No Limits' ,
146
+ } ,
147
+ ] ) ;
148
+ } ) ;
149
+
150
+ test ( 'Should return empty array if role.limits is null or not an object' , ( ) => {
151
+ expect ( getEntitiesForRole ( { limits : null } , data ) ) . toEqual ( [ ] ) ;
152
+ expect ( getEntitiesForRole ( { limits : undefined } , data ) ) . toEqual ( [ ] ) ;
153
+ } ) ;
154
+
155
+ test ( 'Should return empty array when no limits or share properties exist' , ( ) => {
156
+ expect ( getEntitiesForRole ( { } , data ) ) . toEqual ( [ ] ) ;
157
+ } ) ;
158
+
159
+ test ( 'Should return data for entities that have limits and default "No Limits" for others' , ( ) => {
160
+ expect (
161
+ getEntitiesForRole (
162
+ {
163
+ limits : {
164
+ model : { minute : 10 } ,
165
+ model2 : { month : 5 } ,
166
+ } ,
167
+ share : {
168
+ model : { invitationTtl : 3600 } ,
169
+ } ,
170
+ } ,
171
+ data ,
172
+ ) ,
173
+ ) . toEqual ( [
174
+ {
175
+ day : 'No Limits' ,
176
+ minute : 10 ,
177
+ week : 'No Limits' ,
178
+ month : 'No Limits' ,
179
+ name : 'model' ,
180
+ route : ApplicationRoute . Models ,
181
+ type : MenuI18nKey . Models ,
182
+ invitationTtl : 3600 ,
183
+ maxAcceptedUsers : 'No Limits' ,
184
+ } ,
185
+ {
186
+ day : 'No Limits' ,
187
+ minute : 'No Limits' ,
188
+ week : 'No Limits' ,
189
+ month : 5 ,
190
+ invitationTtl : 'No Limits' ,
191
+ maxAcceptedUsers : 'No Limits' ,
72
192
} ,
73
193
] ) ;
74
194
} ) ;
0 commit comments