1- import { getSitemapEntries } from './getSitemapEntries' ;
1+ import { getSitemapEntries , SitemapEntry } from './getSitemapEntries' ;
22
33describe ( 'getSitemapEntries' , ( ) => {
44 test ( 'should generate sitemap entries correctly' , ( ) => {
@@ -12,38 +12,53 @@ describe('getSitemapEntries', () => {
1212 } ;
1313 } ) ;
1414 vi . mock ( '@/helpers/markdownContentManagerHelper' , ( ) => ( {
15- getPosts : ( ) : { lang : string ; slug : string ; categories : string [ ] ; authors : string [ ] } [ ] => [
16- { lang : 'fr' , slug : 'post-1' , categories : [ 'architecture' ] , authors : [ 'author-1' ] } ,
17- { lang : 'en' , slug : 'post-2' , categories : [ 'php' ] , authors : [ 'author-1' ] } ,
15+ getPosts : ( ) : {
16+ lang : string ;
17+ slug : string ;
18+ categories : string [ ] ;
19+ authors : string [ ] ;
20+ date : string ;
21+ cover ?: { path : string } ;
22+ } [ ] => [
23+ {
24+ lang : 'fr' ,
25+ slug : 'post-1' ,
26+ categories : [ 'architecture' ] ,
27+ authors : [ 'author-1' ] ,
28+ date : '2024-01-01T00:00:00' ,
29+ cover : { path : '/imgs/post-1/cover.png' } ,
30+ } ,
31+ { lang : 'en' , slug : 'post-2' , categories : [ 'php' ] , authors : [ 'author-1' ] , date : '2024-01-01T00:00:00' } ,
1832 ] ,
1933 getAuthors : ( ) : { username : string } [ ] => [ { username : 'author-1' } ] ,
2034 } ) ) ;
2135
2236 // Expected result
23- const expectedSitemapEntries = [
24- { priority : 1 , links : [ { lang : 'fr' , url : '/fr/post-1/' } ] } ,
25- { priority : 1 , links : [ { lang : 'en' , url : '/en/post-2/' } ] } ,
37+ const expectedSitemapEntries : SitemapEntry [ ] = [
2638 {
27- priority : 0.8 ,
28- changefreq : 'weekly' ,
39+ links : [ { lang : 'fr' , url : '/fr/post-1/' } ] ,
40+ lastModified : '2024-01-01T00:00:00' ,
41+ image : { url : '/imgs/post-1/cover-w400-h245-x2.avif' } ,
42+ } ,
43+ { links : [ { lang : 'en' , url : '/en/post-2/' } ] , lastModified : '2024-01-01T00:00:00' } ,
44+ {
45+ changeFrequency : 'weekly' ,
2946 links : [
3047 { lang : 'fr' , url : '/' } ,
3148 { lang : 'fr' , url : '/fr/' } ,
3249 { lang : 'en' , url : '/en/' } ,
3350 ] ,
3451 } ,
3552 {
36- priority : 0.7 ,
37- changefreq : 'weekly' ,
53+ changeFrequency : 'weekly' ,
3854 links : [
3955 { lang : 'fr' , url : '/fr/categories/all/' } ,
4056 { lang : 'en' , url : '/en/categories/all/' } ,
4157 ] ,
4258 } ,
43- { priority : 0.7 , changefreq : 'weekly' , links : [ { lang : 'en' , url : '/en/categories/php/' } ] } ,
44- { priority : 0.7 , changefreq : 'weekly' , links : [ { lang : 'fr' , url : '/fr/categories/architecture/' } ] } ,
59+ { changeFrequency : 'weekly' , links : [ { lang : 'en' , url : '/en/categories/php/' } ] } ,
60+ { changeFrequency : 'weekly' , links : [ { lang : 'fr' , url : '/fr/categories/architecture/' } ] } ,
4561 {
46- priority : 0.5 ,
4762 links : [
4863 { lang : 'fr' , url : '/fr/authors/author-1/' } ,
4964 { lang : 'en' , url : '/en/authors/author-1/' } ,
0 commit comments