Skip to content

Instantly share code, notes, and snippets.

@mattheworiordan
Created April 17, 2011 22:01
Show Gist options
  • Save mattheworiordan/924517 to your computer and use it in GitHub Desktop.
Save mattheworiordan/924517 to your computer and use it in GitHub Desktop.
module("Calculator");
test('calculator can perform basic operations', 2, function() {
var calc = new Calculator();
equals (calc.sum(5,10), 15, 'Simple addition');
equals (calc.multiple(5,5), 25, 'Simple multiplication');
});
test('AJAX addition operation', 2, function() {
stop(5000); // wait for up to 5 seconds
var calc = new Calculator();
calc.sendAjaxOperation('+', {
value: 10,
modify_value: 25,
history: '',
failureCallback: function() {
ok(false, 'AJAX request failed');
start();
},
successCallback: function(data) {
equals (data.value, 35);
equals (data.history.length, 1);
start();
}
});
});
get '/javascript_test/:script' => 'javascript_test#render_test'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment