Skip to content

Instantly share code, notes, and snippets.

@ScottMaclure
Created October 31, 2012 22:11
Show Gist options
  • Save ScottMaclure/3990295 to your computer and use it in GitHub Desktop.
Save ScottMaclure/3990295 to your computer and use it in GitHub Desktop.
Jasmine Bootstrap
/**
* Basic skeleton for a Jasmine spec file, to test a jQuery plugin.
*/
describe("myPlugin specs", function () {
var $container;
/**
* Mock mininum amount of html required for plugin to operate.
*/
function createHtml() {
var out = [];
// Build up the most minimal amount of HTML required for your plugin to operate.
out.push('<div class="fn-myPlugin"></div>');
return out.join("");
}
/**
* Setup for testing: bind plugin being tested to html inside the container.
* Do other stuff like Sinon FakeServer, spies, etc.
*/
beforeEach(function () {
$container = $("<div></div>").append(createHtml()).appendTo("body");
});
/**
*
*/
afterEach(function() {
$container.remove();
});
it("will do something", function () {
expect("todo").toBe("done");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment