dwf: refactor to move expects & spec to the global name space so they're

accessible.
This commit is contained in:
Davis W. Frank
2008-11-27 14:30:46 -08:00
commit a2802923e2
10 changed files with 1012 additions and 0 deletions

BIN
test/spinner.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

22
test/test.html Normal file
View File

@@ -0,0 +1,22 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Tests</title>
<link type="text/css" rel="stylesheet" href="../jspec/lib/jspec.css"/>
<script type="text/javascript" src="../jspec/lib/jspec.js"></script>
<script type="text/javascript" src="../lib/jasmine.js"></script>
<script type="text/javascript" src="test.js"></script>
</head>
<body onLoad="JSpecManager.run(htmlReporter);">
<h1>
Running all Jasmine Test Suites
</h1>
<div id="jspec">
<img src="spinner.gif" alt=""/>
</div>
</body>
</html>

101
test/test.js Normal file
View File

@@ -0,0 +1,101 @@
// NOTE: we're using JSpec to test-drive Jasmine. Any syntax
// similarities should be ignored. THIS FILE uses JSpec
with(JSpec('Jasmine expectation results')) {
it('should compare actual and expected values that are equal', function(){
var jasmine_result = expects(true).should_equal(true);
expects_that(jasmine_result).should_equal(true).and_finish();
});
it('should compare actual and expected values that are NOT equal', function(){
var jasmine_result = expects(false).should_equal(true);
expects_that(jasmine_result).should_equal(false).and_finish();
});
it('should be able to store the results of assertions', function(){
Jasmine = jasmine_init(); // re-clears out Jasmine
expects(true).should_equal(true);
expects(false).should_equal(true);
expects_that(Jasmine.results.length).should_equal(2);
expects_that(Jasmine.results[0].passed).should_equal(true);
expects_that(Jasmine.results[1].passed).should_equal(false).and_finish();
});
it('should store a message with a failed expectation', function(){
Jasmine = jasmine_init(); // re-clears out Jasmine
expects(false).should_equal(true);
var expected_message = 'Expected true but got false.';
expects_that(Jasmine.results[0].message).should_equal(expected_message).and_finish();
});
it('should store a default message with a passed expectation', function(){
Jasmine = jasmine_init();
expects(true).should_equal(true);
var expected_message = 'Passed.';
expects_that(Jasmine.results[0].message).should_equal(expected_message).and_finish();
});
}
with(JSpec('Jasmine specs')){
it('can have a description', function(){
Jasmine = jasmine_init();
var a_spec = spec('new spec');
expects_that(a_spec.description).should_equal('new spec').and_finish();
});
it('can execute some statements & expectations', function(){
Jasmine = jasmine_init();
var a_spec = spec('new spec', function() {
var foo = 'bar';
expects(foo).should_equal('bar');
});
a_spec.execute();
expects_that(Jasmine.results.length).should_equal(1)
expects_that(Jasmine.results[0].passed).should_equal(true).and_finish();
});
}
// it('should return true if all of its results are true', function(){
// });
// it('can have multiple assertions', function(){
//
// var jasmine = Jasmine();
// jasmine.expects_that(true).should_equal(true);
//
// var expected_message = 'Passed.';
// expects_that(jasmine.results[0].message).should_equal(expected_message).and_finish();
//
// });
//}
//with(JSpec('Test runner')) {
//
// it('should run a test and collect a result', function(){
//
//
//
//
// });
//
// expects_that(actual).should_equal(expected)u;
//
//
//
//}