Created
March 14, 2012 04:59
-
-
Save steckel/2034199 to your computer and use it in GitHub Desktop.
jQuery.plugin boilerplate spec (for use with Mocha and Should.js)
This file contains 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
root = if window? then window else global | |
root.$ = require("jquery") | |
root.jQuery = $ |
This file contains 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
root = if window? then window else global | |
unless window? | |
require("./support/faux-browser") | |
require("../jquery.plugin") | |
describe 'Chainable', -> | |
describe '$("div.element").pluginName()', -> | |
it 'should return $("div.element") so that other jQuery methods can be chained also called upon', -> | |
$jQueryElem = $("<div id='content'></div>") | |
$jQueryElem.pluginName().should.eql $jQueryElem | |
describe 'Plugin Options', -> | |
describe '$.fn.pluginName.options', -> | |
it 'should contain the default options', -> | |
$.fn.pluginName.defaults.should.be.eql | |
some: "options" | |
also: "others" | |
describe '$.fn.pluginName({some:"newOptions", also:"more"})', -> | |
it 'should overwrite the default options that are mentioned', -> | |
pluginObjectName = new root.PluginObjectName() | |
pluginObjectName.init | |
some: "newOptions" | |
also: "more" | |
pluginObjectName.options.should.be.eql | |
some: "newOptions" | |
also: "more" | |
describe '$.fn.pluginName({some:"newOptions"})', -> | |
it 'should overwrite the default options that are mentioned but, ignore ones that aren\'t', -> | |
pluginObjectName = new root.PluginObjectName() | |
pluginObjectName.init | |
some: "newOptions" | |
pluginObjectName.options.should.be.eql | |
some: "newOptions" | |
also: "others" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment