Skip to content

Instantly share code, notes, and snippets.

@jazzdan
Last active December 12, 2015 07:49
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 jazzdan/4739858 to your computer and use it in GitHub Desktop.
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
class KeyValue
hello: ->
alert "Hello world..."
window.KeyValue = this
// 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);
describe 'KeyValue', ->
k = null
beforeEach ->
k = new KeyValue()
it 'can run a test', ->
expected = 2
result = 1 + 1
expect(result).toBe expected
// 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);
<!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>
@jazzdan
Copy link
Author

jazzdan commented Feb 8, 2013

From JS Console

KeyValue
=> function KeyValue() {}

@colbyr
Copy link

colbyr commented Feb 8, 2013

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