Skip to content

Commit

Permalink
Flesh out existing tests to incorporate sitemap func
Browse files Browse the repository at this point in the history
  • Loading branch information
NJKode committed Apr 8, 2021
1 parent 253a1c3 commit 7e311a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ module.exports = {
const otherFiles = await this.clone_assets(options, sourceFiles.other);
const cssExitCode = await this.rewrite_css(options, sourceFiles.css);
const htmlExitCode = await this.rewrite_html(options, sourceFiles.html);
const sitemapExitCode = await this.rewrite_sitemap(options);

if (!otherFiles || cssExitCode > 0 || htmlExitCode > 0) {
if (!otherFiles || cssExitCode > 0 || htmlExitCode > 0 || sitemapExitCode > 0) {
log.error('There was an error building your site 😓');
return 1;
}
Expand Down
19 changes: 19 additions & 0 deletions test/runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,15 @@ describe('build', function () {
let cloneAssetsStub;
let rewriteCssStub;
let rewriteHtmlStub;
let rewriteSitemapStub;

before(function () {
cleanStub = sinon.stub(runner, 'clean');
fetchStub = sinon.stub(runner, '_fetchAllFiles');
cloneAssetsStub = sinon.stub(runner, 'clone_assets');
rewriteCssStub = sinon.stub(runner, 'rewrite_css');
rewriteHtmlStub = sinon.stub(runner, 'rewrite_html');
rewriteSitemapStub = sinon.stub(runner, 'rewrite_sitemap');
});

context('clean fails', function () {
Expand Down Expand Up @@ -272,13 +274,29 @@ describe('build', function () {
});
});

context('rewrite_sitemap fails', function () {
before(function () {
cleanStub.returns([]);
fetchStub.returns([]);
cloneAssetsStub.returns([]);
rewriteCssStub.returns(0);
rewriteHtmlStub.returns(0);
rewriteSitemapStub.returns(1);
});
it('should return with exit code 1', async function () {
const result = await runner.build(testOp);
expect(result).to.equal(1);
});
});

context('everything works', function () {
before(function () {
cleanStub.returns([]);
fetchStub.returns([]);
cloneAssetsStub.returns([]);
rewriteCssStub.returns(0);
rewriteHtmlStub.returns(0);
rewriteSitemapStub.returns(0);
});
it('should return with exit code 0', async function () {
const result = await runner.build(testOp);
Expand All @@ -292,6 +310,7 @@ describe('build', function () {
cloneAssetsStub.restore();
rewriteCssStub.restore();
rewriteHtmlStub.restore();
rewriteSitemapStub.restore();
});
});

Expand Down

0 comments on commit 7e311a6

Please sign in to comment.