Skip to content

Instantly share code, notes, and snippets.

@gonzedge
Created November 10, 2011 16:36
Show Gist options
  • Save gonzedge/1355322 to your computer and use it in GitHub Desktop.
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
npm install -g jsdom
npm install -g jquery
(($) ->
$.fn.reverse = [].reverse
)(jQuery)
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]
jasmine-node --coffee spec/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment