Last active
December 12, 2015 07:49
-
-
Save jazzdan/4739858 to your computer and use it in GitHub Desktop.
Jasmine Testing with Coffeescript because just learning of those at a time wasn't enough. I'll just put in the compiled JS though
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
class KeyValue | |
hello: -> | |
alert "Hello world..." | |
window.KeyValue = this |
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
// Generated by CoffeeScript 1.4.0 | |
(function() { | |
var KeyValue; | |
KeyValue = (function() { | |
function KeyValue() {} | |
KeyValue.prototype.hello = function() { | |
return alert("Hello world..."); | |
}; | |
window.KeyValue = KeyValue; | |
return KeyValue; | |
})(); | |
}).call(this); |
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
describe 'KeyValue', -> | |
k = null | |
beforeEach -> | |
k = new KeyValue() | |
it 'can run a test', -> | |
expected = 2 | |
result = 1 + 1 | |
expect(result).toBe expected |
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
// Generated by CoffeeScript 1.4.0 | |
(function() { | |
describe('KeyValue', function() { | |
var k; | |
k = null; | |
beforeEach(function() { | |
return k = new KeyValue(); | |
}); | |
return it('can run a test', function() { | |
var expected, result; | |
expected = 2; | |
result = 1 + 1; | |
return expect(result).toBe(expected); | |
}); | |
}); | |
}).call(this); |
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<title>Jasmine Spec Runner</title> | |
<link rel="shortcut icon" type="image/png" href="jasmine/lib/jasmine-1.3.1/jasmine_favicon.png"> | |
<link rel="stylesheet" type="text/css" href="jasmine/lib/jasmine-1.3.1/jasmine.css"> | |
<script type="text/javascript" src="jasmine/lib/jasmine-1.3.1/jasmine.js"></script> | |
<script type="text/javascript" src="jasmine/lib/jasmine-1.3.1/jasmine-html.js"></script> | |
<!-- include source files here... --> | |
<script type="text/javascript" src="js/keyValue.js"></script> | |
<!-- include spec files here... --> | |
<script type="text/javascript" src="jasmine/spec/SpecHelper.js"></script> | |
<script type="text/javascript" src="jasmine/spec/KeyValueSpec.js"></script> | |
<script type="text/javascript"> | |
(function() { | |
var jasmineEnv = jasmine.getEnv(); | |
jasmineEnv.updateInterval = 1000; | |
var htmlReporter = new jasmine.HtmlReporter(); | |
jasmineEnv.addReporter(htmlReporter); | |
jasmineEnv.specFilter = function(spec) { | |
return htmlReporter.specFilter(spec); | |
}; | |
var currentWindowOnload = window.onload; | |
window.onload = function() { | |
if (currentWindowOnload) { | |
currentWindowOnload(); | |
} | |
execJasmine(); | |
}; | |
function execJasmine() { | |
jasmineEnv.execute(); | |
} | |
})(); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
class KeyValue
hello: ->
alert "hello world..."
window.KeyValue = KeyValue
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From JS Console
KeyValue
=> function KeyValue() {}