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