@@ -14,11 +14,9 @@ describe('BookRuleEvaluatorService', () => {
1414
1515 const createBook = ( overrides : Partial < Book > = { } ) : Book => ( {
1616 id : 1 ,
17- bookType : 'EPUB' ,
17+ primaryFile : { id : 1 , bookId : 1 , bookType : 'EPUB' , fileName : 'test.epub' , filePath : '/path/to/test.epub' , fileSizeKb : 1024 } ,
1818 libraryId : 1 ,
1919 libraryName : 'Test Library' ,
20- fileName : 'test.epub' ,
21- filePath : '/path/to/test.epub' ,
2220 readStatus : ReadStatus . UNREAD ,
2321 shelves : [ ] ,
2422 metadata : {
@@ -33,7 +31,7 @@ describe('BookRuleEvaluatorService', () => {
3331
3432 describe ( 'fileType filtering' , ( ) => {
3533 it ( 'should filter EPUB books correctly when rule uses "epub"' , ( ) => {
36- const book = createBook ( { bookType : 'EPUB' } ) ;
34+ const book = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'EPUB' } } ) ;
3735 const group : GroupRule = {
3836 name : 'test' ,
3937 type : 'group' ,
@@ -52,7 +50,7 @@ describe('BookRuleEvaluatorService', () => {
5250 } ) ;
5351
5452 it ( 'should filter PDF books correctly when rule uses "pdf"' , ( ) => {
55- const book = createBook ( { bookType : 'PDF' } ) ;
53+ const book = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'PDF' } } ) ;
5654 const group : GroupRule = {
5755 name : 'test' ,
5856 type : 'group' ,
@@ -71,7 +69,7 @@ describe('BookRuleEvaluatorService', () => {
7169 } ) ;
7270
7371 it ( 'should handle CBX books correctly for cbr, cbz, and cb7 rules' , ( ) => {
74- const book = createBook ( { bookType : 'CBX' } ) ;
72+ const book = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'CBX' } } ) ;
7573
7674 const cbrGroup : GroupRule = {
7775 name : 'test' ,
@@ -117,7 +115,7 @@ describe('BookRuleEvaluatorService', () => {
117115 } ) ;
118116
119117 it ( 'should handle not_equals operator correctly' , ( ) => {
120- const epubBook = createBook ( { bookType : 'EPUB' } ) ;
118+ const epubBook = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'EPUB' } } ) ;
121119 const group : GroupRule = {
122120 name : 'test' ,
123121 type : 'group' ,
@@ -134,14 +132,14 @@ describe('BookRuleEvaluatorService', () => {
134132 const result = service . evaluateGroup ( epubBook , group ) ;
135133 expect ( result ) . toBe ( true ) ;
136134
137- const pdfBook = createBook ( { bookType : 'PDF' } ) ;
135+ const pdfBook = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'PDF' } } ) ;
138136 const result2 = service . evaluateGroup ( pdfBook , group ) ;
139137 expect ( result2 ) . toBe ( false ) ;
140138 } ) ;
141139
142140 it ( 'should filter EPUB books correctly when rule uses "not_equals" with "epub"' , ( ) => {
143- const epubBook = createBook ( { bookType : 'EPUB' } ) ;
144- const pdfBook = createBook ( { bookType : 'PDF' } ) ;
141+ const epubBook = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'EPUB' } } ) ;
142+ const pdfBook = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'PDF' } } ) ;
145143
146144 const group : GroupRule = {
147145 name : 'test' ,
@@ -165,7 +163,7 @@ describe('BookRuleEvaluatorService', () => {
165163 describe ( 'evaluateGroup' , ( ) => {
166164 it ( 'should evaluate group rules with AND logic' , ( ) => {
167165 const book = createBook ( {
168- bookType : 'EPUB'
166+ primaryFile : { id : 1 , bookId : 1 , bookType : 'EPUB' }
169167 } ) ;
170168
171169 const group : GroupRule = {
@@ -183,7 +181,7 @@ describe('BookRuleEvaluatorService', () => {
183181 } ) ;
184182
185183 it ( 'should evaluate group rules with OR logic' , ( ) => {
186- const book = createBook ( { bookType : 'PDF' } ) ;
184+ const book = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'PDF' } } ) ;
187185
188186 const group : GroupRule = {
189187 name : 'test' ,
@@ -1177,7 +1175,7 @@ describe('BookRuleEvaluatorService', () => {
11771175 } ) ;
11781176
11791177 it ( 'should handle includes_any with fileType mapping' , ( ) => {
1180- const book = createBook ( { bookType : 'CBX' } ) ;
1178+ const book = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'CBX' } } ) ;
11811179 expect ( service . evaluateGroup ( book , rule ( 'fileType' , 'includes_any' , [ 'cbr' , 'pdf' ] ) ) ) . toBe ( true ) ;
11821180 } ) ;
11831181
@@ -1189,17 +1187,17 @@ describe('BookRuleEvaluatorService', () => {
11891187
11901188 describe ( 'fileType mapping edge cases' , ( ) => {
11911189 it ( 'should map azw to azw3' , ( ) => {
1192- const book = createBook ( { bookType : 'AZW3' } ) ;
1190+ const book = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'AZW3' } } ) ;
11931191 expect ( service . evaluateGroup ( book , rule ( 'fileType' , 'equals' , 'azw' ) ) ) . toBe ( true ) ;
11941192 } ) ;
11951193
11961194 it ( 'should handle MOBI bookType' , ( ) => {
1197- const book = createBook ( { bookType : 'MOBI' } ) ;
1195+ const book = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'MOBI' } } ) ;
11981196 expect ( service . evaluateGroup ( book , rule ( 'fileType' , 'equals' , 'mobi' ) ) ) . toBe ( true ) ;
11991197 } ) ;
12001198
12011199 it ( 'should handle not_equals with fileType cbr mapping' , ( ) => {
1202- const book = createBook ( { bookType : 'PDF' } ) ;
1200+ const book = createBook ( { primaryFile : { id : 1 , bookId : 1 , bookType : 'PDF' } } ) ;
12031201 expect ( service . evaluateGroup ( book , rule ( 'fileType' , 'not_equals' , 'cbr' ) ) ) . toBe ( true ) ;
12041202 } ) ;
12051203 } ) ;
0 commit comments