Last active
December 21, 2015 06:59
-
-
Save thom4parisot/6267889 to your computer and use it in GitHub Desktop.
Stubbing grunt.task.current.target.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use strict"; | |
| var grunt = require("grunt"); | |
| var chai = require("chai"); | |
| var expect = chai.expect; | |
| var sinon = require("sinon"); | |
| var task = require('../index.js')(grunt).sass_compile; | |
| describe("grunt sass_compile task", function(){ | |
| var gruntTaskStub, sandbox, originalTarget; | |
| beforeEach(function(){ | |
| sandbox = sinon.sandbox.create(); | |
| gruntTaskStub = sandbox.stub(grunt.task, "run"); | |
| }); | |
| afterEach(function(){ | |
| sandbox.restore(); | |
| }); | |
| it("should trigger the sass:service subtask for a given argument", function(){ | |
| sandbox.stub(grunt.task.current, "target", 'news'); | |
| task.runTask(); | |
| expect(gruntTaskStub.calledWithExactly(["sass:service:news"])).to.be.true; | |
| }); | |
| it("should trigger an error if the service is empty", function(){ | |
| sandbox.stub(grunt.task.current, "target", ""); | |
| expect(task.runTask).to.throw(Error); | |
| sandbox.stub(grunt.task.current, "target", undefined); | |
| expect(task.runTask).to.throw(Error); | |
| }); | |
| it("should trigger an error if the service does not exist", function(){ | |
| sandbox.stub(grunt.task.current, "target", 'ilikecheese'); | |
| expect(task.runTask).to.throw(Error); | |
| }); | |
| it("should trigger an error if the service is not allowed to be compiled", function(){ | |
| sandbox.stub(grunt.task.current, "target", 'journalism'); | |
| expect(task.runTask).to.throw(Error); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment