@@ -57,7 +57,9 @@ describe('Feed generator', () => {
5757 await Post . insert ( [
5858 { source : 'foo' , slug : 'foo' , content : '<h6>TestHTML</h6>' , date : 1e8 } ,
5959 { source : 'bar' , slug : 'bar' , date : 1e8 + 1 } ,
60- { source : 'baz' , slug : 'baz' , title : 'With Image' , image : 'test.png' , date : 1e8 - 1 }
60+ { source : 'baz' , slug : 'baz' , title : 'With Image' , image : 'test.png' , date : 1e8 - 1 } ,
61+ { source : 'date' , slug : 'date' , title : 'date' , date : 1e8 - 2 , updated : undefined } ,
62+ { source : 'updated' , slug : 'updated' , title : 'updated' , date : 1e8 - 2 , updated : 1e8 + 10 }
6163 ] ) ;
6264 posts = Post . sort ( '-date' ) ;
6365 locals = hexo . locals . toObject ( ) ;
@@ -396,6 +398,40 @@ describe('Feed generator', () => {
396398 feed_url : 'http://localhost/atom.xml'
397399 } ) ) ;
398400 } ) ;
401+
402+ it ( 'no updated date' , async ( ) => {
403+ hexo . config . feed = {
404+ type : 'atom' ,
405+ path : 'atom.xml'
406+ } ;
407+ hexo . config = Object . assign ( hexo . config , urlConfig ) ;
408+ const feedCfg = hexo . config . feed ;
409+ const result = generator ( locals , feedCfg . type , feedCfg . path ) ;
410+
411+ const { items } = await p ( result . data ) ;
412+ const post = items . filter ( ( { title } ) => title === 'date' ) ;
413+ const { date, updated } = post [ 0 ] ;
414+
415+ updated . should . eql ( date ) ;
416+ } ) ;
417+
418+ it ( 'updated date' , async ( ) => {
419+ hexo . config . feed = {
420+ type : 'atom' ,
421+ path : 'atom.xml'
422+ } ;
423+ hexo . config = Object . assign ( hexo . config , urlConfig ) ;
424+ const feedCfg = hexo . config . feed ;
425+ const result = generator ( locals , feedCfg . type , feedCfg . path ) ;
426+
427+ const { items } = await p ( result . data ) ;
428+ const post = items . filter ( ( { title } ) => title === 'updated' ) ;
429+ const { date, updated } = post [ 0 ] ;
430+ const expected = new Date ( 1e8 + 10 ) . toISOString ( ) ;
431+
432+ updated . should . eql ( expected ) ;
433+ date . should . not . eql ( updated ) ;
434+ } ) ;
399435} ) ;
400436
401437it ( 'No posts' , ( ) => {
0 commit comments