@@ -101,22 +101,93 @@ describe('Get year', () => {
101
101
} ) ;
102
102
103
103
describe ( 'Get color rating' , ( ) => {
104
- // test('Black', () => {
105
- // const movie = getUserRatingColorRating(movies[7]);
106
- // expect(movie).toEqual<CSFDColorRating>('bad');
107
- // });
108
- // test('Gray', () => {
109
- // const movie = getUserRatingColorRating(movies[29]);
110
- // expect(movie).toEqual<CSFDColorRating>('unknown');
111
- // });
112
- test ( 'Blue' , ( ) => {
104
+ test ( 'Blue color should return average' , ( ) => {
113
105
const movie = getUserRatingColorRating ( movies [ 3 ] ) ;
114
106
expect ( movie ) . toEqual < CSFDColorRating > ( 'average' ) ;
115
107
} ) ;
116
- test ( 'Red' , ( ) => {
108
+
109
+ test ( 'Red color should return good' , ( ) => {
117
110
const movie = getUserRatingColorRating ( movies [ 1 ] ) ;
118
111
expect ( movie ) . toEqual < CSFDColorRating > ( 'good' ) ;
119
112
} ) ;
113
+
114
+ test ( 'Grey color should return bad' , ( ) => {
115
+ // Create a mock element with grey class
116
+ const mockElement = parse ( `
117
+ <tr>
118
+ <td class="name">
119
+ <span class="icon grey"></span>
120
+ </td>
121
+ </tr>
122
+ ` ) ;
123
+ const result = getUserRatingColorRating ( mockElement ) ;
124
+ expect ( result ) . toEqual < CSFDColorRating > ( 'bad' ) ;
125
+ } ) ;
126
+
127
+ test ( 'Lightgrey color should return unknown' , ( ) => {
128
+ // Create a mock element with lightgrey class
129
+ const mockElement = parse ( `
130
+ <tr>
131
+ <td class="name">
132
+ <span class="icon lightgrey"></span>
133
+ </td>
134
+ </tr>
135
+ ` ) ;
136
+ const result = getUserRatingColorRating ( mockElement ) ;
137
+ expect ( result ) . toEqual < CSFDColorRating > ( 'unknown' ) ;
138
+ } ) ;
139
+
140
+ test ( 'Unknown/invalid color should return unknown (default case)' , ( ) => {
141
+ // Create a mock element with an unknown color class
142
+ const mockElement = parse ( `
143
+ <tr>
144
+ <td class="name">
145
+ <span class="icon purple"></span>
146
+ </td>
147
+ </tr>
148
+ ` ) ;
149
+ const result = getUserRatingColorRating ( mockElement ) ;
150
+ expect ( result ) . toEqual < CSFDColorRating > ( 'unknown' ) ;
151
+ } ) ;
152
+
153
+ test ( 'No color class should return unknown (default case)' , ( ) => {
154
+ // Create a mock element with no color class
155
+ const mockElement = parse ( `
156
+ <tr>
157
+ <td class="name">
158
+ <span class="icon"></span>
159
+ </td>
160
+ </tr>
161
+ ` ) ;
162
+ const result = getUserRatingColorRating ( mockElement ) ;
163
+ expect ( result ) . toEqual < CSFDColorRating > ( 'unknown' ) ;
164
+ } ) ;
165
+
166
+ test ( 'Empty string color should return unknown (default case)' , ( ) => {
167
+ // Create a mock element with empty class
168
+ const mockElement = parse ( `
169
+ <tr>
170
+ <td class="name">
171
+ <span class="icon "></span>
172
+ </td>
173
+ </tr>
174
+ ` ) ;
175
+ const result = getUserRatingColorRating ( mockElement ) ;
176
+ expect ( result ) . toEqual < CSFDColorRating > ( 'unknown' ) ;
177
+ } ) ;
178
+
179
+ test ( 'Multiple classes with valid color should work' , ( ) => {
180
+ // Create a mock element with multiple classes including a valid color
181
+ const mockElement = parse ( `
182
+ <tr>
183
+ <td class="name">
184
+ <span class="icon some-other-class another-class red"></span>
185
+ </td>
186
+ </tr>
187
+ ` ) ;
188
+ const result = getUserRatingColorRating ( mockElement ) ;
189
+ expect ( result ) . toEqual < CSFDColorRating > ( 'good' ) ;
190
+ } ) ;
120
191
} ) ;
121
192
122
193
describe ( 'Get date' , ( ) => {
0 commit comments