Created
June 5, 2013 04:42
-
-
Save danielbreves/5711652 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(function() { | |
return { | |
events: { | |
'app.activated':'appActivated', | |
'*.changed': function(evt) { | |
this.eventsFired.push(evt.propertyName); | |
} | |
}, | |
appActivated: function(data) { | |
this.runTests(); | |
}, | |
runTests: function() { | |
var ticket = this.ticket(), | |
subject = Date(), | |
email = "[email protected]"; | |
this.eventsFired = []; | |
ticket.subject( subject ); | |
this.testLater('ticket.subject should fire change events', function() { | |
return ticket.subject() === subject && _.contains(this.eventsFired, 'ticket.subject'); | |
}, 500); | |
ticket.requester({ email: email }); | |
this.testLater('ticket.requester.email should be set to [email protected].', function() { | |
return ticket.requester().email() === email; | |
}, 500); | |
}, | |
testLater: function(description, callback, wait) { | |
var test = _.bind(this.test, this); | |
_.delay(test, 500, description, callback); | |
}, | |
test: function(description, callback) { | |
if (callback.call(this)) { | |
this._renderResult('success', description); | |
} else { | |
this._renderResult('error', description); | |
} | |
}, | |
_renderResult: function(result, message) { | |
var html = this.renderTemplate('result', { | |
result: result, | |
message: message | |
}); | |
this.$().append(html); | |
} | |
}; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment