Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
add test for example from readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav Kosinov authored and Vladislav Kosinov committed May 5, 2015
1 parent d20d42a commit cca9022
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
13 changes: 13 additions & 0 deletions test/data/multiple-files/from-readme/sitemap-0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://vk.com/movies/video-1</loc>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>http://vk.com/movies/video-n</loc>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
13 changes: 13 additions & 0 deletions test/data/multiple-files/from-readme/sitemap-1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://vk.com/books/book-1</loc>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>http://vk.com/books/book-n</loc>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
9 changes: 9 additions & 0 deletions test/data/multiple-files/from-readme/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>http://vk.com/sitemap-0.xml</loc>
</sitemap>
<sitemap>
<loc>http://vk.com/sitemap-1.xml</loc>
</sitemap>
</sitemapindex>
29 changes: 27 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ describe('method addUrl', function () {
sitemap.addUrl('http://google.com/page1');
});

it('should accept url as object ', function () {
it('should accept url as object', function () {
sitemap.addUrl({url: 'http://google.com/page1'});
});

it('should accept url as array of strings ', function () {
it('should accept url as array of strings', function () {
sitemap.addUrl(['http://google.com/page1']);
});

Expand Down Expand Up @@ -222,3 +222,28 @@ describe('toXML()', function () {
});

});

describe('example from README', function () {
it('should work like a master', function () {
var host = 'http://vk.com';

var sm = new Sitemap({hostName: host});

var movies = new Sitemap({hostName: host});
movies.addUrl('http://vk.com/movies/video-1');
movies.addUrl('http://vk.com/movies/video-n');

var books = new Sitemap({hostName: host});
books.addUrl('http://vk.com/books/book-1');
books.addUrl('http://vk.com/books/book-n');

sm.addSitemap(movies);
sm.addSitemap(books);

var files = sm.toXML();

files.forEach(function eachShouldBeEqual(sm) {
sm.xml.should.equal(dataExpected['multiple-files']['from-readme'][sm.fileName]);
});
})
});

0 comments on commit cca9022

Please sign in to comment.