Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more specs and bump version to 1.3
- Loading branch information
Matthieu Aussaguel
committed
Jun 14, 2012
1 parent
0ee9334
commit d38fc5c
Showing
6 changed files
with
55 additions
and
30 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,26 +1,42 @@ | |||
describe "PluginName", -> | describe 'PluginName', -> | ||
options = | options = | ||
message: 'Hello World' | message: 'Hello World' | ||
callback: (element, message) -> $(element).append("#{message}!") | callback: (element, text) -> $(element).append("#{text}!") | ||
|
|
||
beforeEach -> | beforeEach -> | ||
loadFixtures 'fragment.html' | loadFixtures 'fragment.html' | ||
@$element = $('#fixtures') | @$element = $('#fixtures') | ||
|
|
||
it "should be available on the jQuery object", -> | it 'should be available on the jQuery object', -> | ||
expect($.fn.pluginName).toBeDefined() | expect($.fn.pluginName).toBeDefined() | ||
|
|
||
it "should be chainable", -> | it 'should be chainable', -> | ||
expect(@$element.pluginName(options)).toBe(@$element) | expect(@$element.pluginName(options)).toBe(@$element) | ||
|
|
||
it "should offers default values", -> | it 'should offers default values', -> | ||
plugin = new $.pluginName(@$element[0], options) | plugin = new $.pluginName(@$element[0], options) | ||
|
|||
expect(plugin.defaults).toBeDefined() | expect(plugin.defaults).toBeDefined() | ||
|
|
||
it "should overwrites the settings", -> | it 'should overwrites the settings', -> | ||
plugin = new $.pluginName(@$element[0], options) | plugin = new $.pluginName(@$element[0], options) | ||
|
|||
expect(plugin.settings.message).toBe(options.message) | expect(plugin.settings.message).toBe(options.message) | ||
expect(plugin.settings.callback).toBe(options.callback) | expect(plugin.settings.callback).toBe(options.callback) | ||
|
|
||
it "should execute the callback method", -> | it 'should execute the callback append the hello world! to the element', -> | ||
expect(@$element.pluginName(options)).toHaveText 'Hello World!' | @$element.pluginName(options) | ||
|
|||
expect(@$element).toHaveText 'Hello World!' | |||
|
|||
it 'should execute the callback the right arguments', -> | |||
foo = jasmine.createSpy('foo') | |||
plugin = new $.pluginName(@$element, {message: 'Hello World', callback: foo}) | |||
|
|||
expect(foo).toHaveBeenCalled() | |||
expect(foo.mostRecentCall.args[0]).toBe @$element | |||
expect(foo.mostRecentCall.args[1]).toBe "Hello World" | |||
|
|||
|
|||
|
|||
|
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