Created
November 10, 2011 16:36
-
-
Save gonzedge/1355322 to your computer and use it in GitHub Desktop.
Unit testing the jQuery Rambling Slider – Part 2 – The DOM, jQuery and node.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
npm install -g jsdom | |
npm install -g 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
(($) -> | |
$.fn.reverse = [].reverse | |
)(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
global.window = require('jsdom').jsdom().createWindow() | |
global.jQuery = require 'jquery' | |
require '../src/array_extensions' | |
require '../src/jquery.plugins' | |
$ = jQuery | |
describe 'jQuery Plugins', -> | |
html_box = null | |
beforeEach -> | |
html_box = $ '<div></div>' | |
html_box.append '<ul><li></li><li></li><li></li><li></li></ul>' | |
describe 'when reversing a jQuery array', -> | |
original_array = null | |
array = null | |
beforeEach -> | |
array = html_box.find 'li' | |
original_array = html_box.find 'li' | |
array = array.reverse() | |
it 'should return the elements in reverse order', -> | |
for i in [0...array.length] | |
expect(array[i]).toEqual original_array[array.length - 1 - i] |
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
jasmine-node --coffee spec/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment