Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
achauvinhameau committed Aug 26, 2017
1 parent 64cf502 commit e7e6572
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,31 @@ describe('Sitemap generator', function() {
var result = generator(locals);

result.path.should.eql('sitemap.xml');

// get the lastmod value for the index page (autogenerated)
var $ = cheerio.load(result.data);
var _lm = "";
$('urlset').find('url').each(function(i) {
if ($(this).children('loc').text() === "http://yoursite.com") {
_lm = $(this).children('lastmod').text();
}
});

result.data.should.eql(sitemapTmpl.render({
config: hexo.config,
posts: posts.toArray()
posts: posts.toArray(),
sNow: _lm // inject the same moddate
}));

var $ = cheerio.load(result.data);

$('urlset').find('url').each(function(i) {
$(this).children('loc').text().should.eql(posts.eq(i).permalink);
$(this).children('lastmod').text().should.eql(posts.eq(i).updated.toISOString());
// do not check the auto-generated index page, all others should have same
// loc and lastmod (from post)
if ($(this).children('loc').text() !== "http://yoursite.com") {
$(this).children('loc').text().should.eql(posts.eq(i).permalink);
$(this).children('lastmod').text().should.eql(posts.eq(i).updated.toISOString());
}
});
});

Expand Down

0 comments on commit e7e6572

Please sign in to comment.