Skip to content

Commit

Permalink
Add tests for onCompile()
Browse files Browse the repository at this point in the history
These tests bring the overall code coverage to 100% across the board.
  • Loading branch information
caleb531 committed May 11, 2017
1 parent 03fa25a commit c6ad89e
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,43 @@ describe('rsvg-brunch', function () {

});

describe('onCompile', function () {

let config;
beforeEach(function () {
config = {
plugins: {
rsvg: {
conversions: [
sinon.spy(),
sinon.spy(),
sinon.spy()
]
}
}
};
});

it('should run conversions when librsvg is available', function () {
const plugin = new Plugin(Object.assign(defaultConfig, config));
plugin.handleConversion = sinon.spy();
plugin.onCompile();
const conversions = config.plugins.rsvg.conversions;
sinon.assert.calledWith(plugin.handleConversion, conversions[0]);
sinon.assert.calledWith(plugin.handleConversion, conversions[1]);
sinon.assert.calledWith(plugin.handleConversion, conversions[2]);
});

it('should not run conversions when librsvg is not available', function () {
const plugin = new Plugin(Object.assign(defaultConfig, config));
plugin.handleConversion = sinon.spy();
delete plugin.Rsvg;
plugin.onCompile();
sinon.assert.notCalled(plugin.handleConversion);
});

});

it('should be registered as Brunch plugin', function () {
expect(Plugin.prototype.brunchPlugin).to.be.true;
});
Expand Down

0 comments on commit c6ad89e

Please sign in to comment.