Skip to content

Instantly share code, notes, and snippets.

@mvasilkov
Created October 2, 2012 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvasilkov/3817523 to your computer and use it in GitHub Desktop.
Save mvasilkov/3817523 to your computer and use it in GitHub Desktop.
QUnit test with RequireJS (partial)
define(['events'], function(events) {
module('events.js')
test('Basic methods', function() {
// `register` and `bind`
var str = 'Life is beautiful'
events.register('str_replace')
events.bind('str_replace', function() { str = str.replace('Life', 'Flower') })
events.fire('str_replace')
strictEqual(str, 'Flower is beautiful', 'Can register and fire events (`bind`)')
events.register('str_set')
events.bind('str_set', function(arg) { str = arg })
events.fire('str_set', 'PAINT IT RED')
strictEqual(str, 'PAINT IT RED', 'Can register and fire parameterized events (`bind`)')
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment