@@ -568,21 +568,36 @@ describe('latestArticles', () => {
568
568
value : articleChannelThreshold ,
569
569
} )
570
570
571
+ // create articles
572
+ const [ article1 ] = await articleService . createArticle ( {
573
+ title : 'test' ,
574
+ content : '' ,
575
+ authorId : '1' ,
576
+ } )
577
+ const [ article2 ] = await articleService . createArticle ( {
578
+ title : 'test2' ,
579
+ content : '' ,
580
+ authorId : '1' ,
581
+ } )
582
+ const [ article3 ] = await articleService . createArticle ( {
583
+ title : 'test3' ,
584
+ content : '' ,
585
+ authorId : '1' ,
586
+ } )
587
+
571
588
// create channels
572
589
const channel = await channelService . updateOrCreateChannel ( {
573
590
name : 'test' ,
574
591
description : 'test' ,
575
592
providerId : 'test-latest' ,
576
593
enabled : true ,
577
594
} )
578
-
579
595
const channel2 = await channelService . updateOrCreateChannel ( {
580
596
name : 'test2' ,
581
597
description : 'test2' ,
582
598
providerId : 'test-latest2' ,
583
599
enabled : true ,
584
600
} )
585
-
586
601
const channel3 = await channelService . updateOrCreateChannel ( {
587
602
name : 'test3' ,
588
603
description : 'test3' ,
@@ -594,7 +609,7 @@ describe('latestArticles', () => {
594
609
await atomService . create ( {
595
610
table : 'article_channel' ,
596
611
data : {
597
- articleId : '1' ,
612
+ articleId : article1 . id ,
598
613
channelId : channel . id ,
599
614
score : articleChannelThreshold + 0.1 ,
600
615
enabled : true ,
@@ -603,7 +618,7 @@ describe('latestArticles', () => {
603
618
await atomService . create ( {
604
619
table : 'article_channel' ,
605
620
data : {
606
- articleId : '1' ,
621
+ articleId : article2 . id ,
607
622
channelId : channel2 . id , // disabled channel
608
623
score : articleChannelThreshold + 0.1 ,
609
624
enabled : true ,
@@ -613,7 +628,7 @@ describe('latestArticles', () => {
613
628
await atomService . create ( {
614
629
table : 'article_channel' ,
615
630
data : {
616
- articleId : '2' ,
631
+ articleId : article3 . id ,
617
632
channelId : channel2 . id , // disabled channel
618
633
score : articleChannelThreshold + 0.1 ,
619
634
enabled : true ,
@@ -623,7 +638,7 @@ describe('latestArticles', () => {
623
638
await atomService . create ( {
624
639
table : 'article_channel' ,
625
640
data : {
626
- articleId : '3' ,
641
+ articleId : article3 . id ,
627
642
channelId : channel3 . id ,
628
643
score : articleChannelThreshold + 0.1 ,
629
644
enabled : false , // disabled article channel
@@ -639,9 +654,9 @@ describe('latestArticles', () => {
639
654
excludeChannelArticles : false ,
640
655
} )
641
656
expect ( articles . length ) . toBe ( 3 )
642
- expect ( articles . map ( ( { id } ) => id ) ) . toContain ( '1' )
643
- expect ( articles . map ( ( { id } ) => id ) ) . toContain ( '2' )
644
- expect ( articles . map ( ( { id } ) => id ) ) . toContain ( '3' )
657
+ expect ( articles . map ( ( { id } ) => id ) ) . toContain ( article1 . id )
658
+ expect ( articles . map ( ( { id } ) => id ) ) . toContain ( article2 . id )
659
+ expect ( articles . map ( ( { id } ) => id ) ) . toContain ( article3 . id )
645
660
const [ articlesExcludedChannel , totalCount2 ] =
646
661
await articleService . latestArticles ( {
647
662
maxTake : 500 ,
@@ -651,10 +666,12 @@ describe('latestArticles', () => {
651
666
excludeSpam : false ,
652
667
excludeChannelArticles : true ,
653
668
} )
654
- expect ( articlesExcludedChannel . length ) . toBe ( 1 )
655
- expect ( articlesExcludedChannel . map ( ( { id } ) => id ) ) . not . toContain ( '1' )
656
- expect ( articlesExcludedChannel . map ( ( { id } ) => id ) ) . toContain ( '2' )
657
- expect ( articlesExcludedChannel . map ( ( { id } ) => id ) ) . toContain ( '3' )
669
+ expect ( articlesExcludedChannel . length ) . toBe ( 2 )
670
+ expect ( articlesExcludedChannel . map ( ( { id } ) => id ) ) . not . toContain (
671
+ article1 . id
672
+ )
673
+ expect ( articlesExcludedChannel . map ( ( { id } ) => id ) ) . toContain ( article2 . id )
674
+ expect ( articlesExcludedChannel . map ( ( { id } ) => id ) ) . toContain ( article3 . id )
658
675
expect ( totalCount1 ) . toBe ( totalCount2 + 1 )
659
676
} )
660
677
} )
0 commit comments