dwf/rva: minor Jasmine cleanup
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
</h1>
|
||||
<div id="icon_wrapper">
|
||||
<span id="icons"></span>
|
||||
<img id="spinner" src="spinner.gif" alt="" />
|
||||
<img id="spinner" src="../images/spinner.gif" alt="" />
|
||||
</div>
|
||||
<div id="report">
|
||||
<div id="results_summary" style="display:none;">
|
||||
|
||||
136
test/bootstrap.js
vendored
136
test/bootstrap.js
vendored
@@ -136,22 +136,26 @@ var testSpecs = function () {
|
||||
var testAsyncSpecs = function () {
|
||||
var foo = 0;
|
||||
|
||||
var a_spec = it('simple queue test').
|
||||
runs(function () {
|
||||
foo++;
|
||||
}).then(function() {
|
||||
this.expects_that(foo).should_equal(1)
|
||||
var a_spec = it('simple queue test', function () {
|
||||
runs(function () {
|
||||
foo++;
|
||||
});
|
||||
runs(function () {
|
||||
this.expects_that(foo).should_equal(1)
|
||||
});
|
||||
});
|
||||
|
||||
reporter.test(a_spec.queue.length === 2,
|
||||
'Spec queue length is not 2');
|
||||
|
||||
foo = 0;
|
||||
a_spec = it('spec w/ queued statments').
|
||||
runs(function () {
|
||||
foo++;
|
||||
}).then(function() {
|
||||
this.expects_that(foo).should_equal(1);
|
||||
a_spec = it('spec w/ queued statments', function () {
|
||||
runs(function () {
|
||||
foo++;
|
||||
});
|
||||
runs(function () {
|
||||
this.expects_that(foo).should_equal(1);
|
||||
});
|
||||
});
|
||||
|
||||
a_spec.execute();
|
||||
@@ -162,14 +166,16 @@ var testAsyncSpecs = function () {
|
||||
'No call to waits(): Queued expectation failed');
|
||||
|
||||
foo = 0;
|
||||
a_spec = it('spec w/ queued statments').
|
||||
runs(function () {
|
||||
setTimeout(function() {
|
||||
foo++
|
||||
}, 500);
|
||||
}).waits(1000).
|
||||
then(function() {
|
||||
this.expects_that(foo).should_equal(1);
|
||||
a_spec = it('spec w/ queued statments', function () {
|
||||
runs(function () {
|
||||
setTimeout(function() {
|
||||
foo++
|
||||
}, 500);
|
||||
});
|
||||
waits(1000);
|
||||
runs(function() {
|
||||
this.expects_that(foo).should_equal(1);
|
||||
});
|
||||
});
|
||||
|
||||
var mockSuite = {
|
||||
@@ -185,22 +191,25 @@ var testAsyncSpecs = function () {
|
||||
waitForDone(a_spec, mockSuite);
|
||||
|
||||
var bar = 0;
|
||||
var another_spec = it('spec w/ queued statments').
|
||||
runs(function () {
|
||||
setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
}).
|
||||
waits(500).
|
||||
then(function () {
|
||||
setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
}).
|
||||
waits(1500).
|
||||
then(function() {
|
||||
this.expects_that(bar).should_equal(2);
|
||||
var another_spec = it('spec w/ queued statments', function () {
|
||||
runs(function () {
|
||||
setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
|
||||
});
|
||||
waits(500);
|
||||
runs(function () {
|
||||
setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
});
|
||||
waits(500);
|
||||
runs(function () {
|
||||
this.expects_that(bar).should_equal(2);
|
||||
});
|
||||
});
|
||||
|
||||
mockSuite = {
|
||||
next: function() {
|
||||
reporter.test((another_spec.queue.length === 3),
|
||||
@@ -215,17 +224,19 @@ var testAsyncSpecs = function () {
|
||||
waitForDone(another_spec, mockSuite);
|
||||
|
||||
var baz = 0;
|
||||
var yet_another_spec = it('spec w/ async fail').
|
||||
runs(function () {
|
||||
setTimeout(function() {
|
||||
baz++;
|
||||
}, 250);
|
||||
}).
|
||||
waits(100).
|
||||
then(function() {
|
||||
this.expects_that(baz).should_equal(1);
|
||||
var yet_another_spec = it('spec w/ async fail', function () {
|
||||
runs(function () {
|
||||
setTimeout(function() {
|
||||
baz++;
|
||||
}, 250);
|
||||
});
|
||||
waits(100);
|
||||
runs(function() {
|
||||
this.expects_that(baz).should_equal(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
mockSuite = {
|
||||
next: function() {
|
||||
|
||||
@@ -244,21 +255,22 @@ var testAsyncSpecs = function () {
|
||||
|
||||
var testAsyncSpecsWithMockSuite = function () {
|
||||
var bar = 0;
|
||||
var another_spec = it('spec w/ queued statments').
|
||||
runs(function () {
|
||||
setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
}).
|
||||
waits(500).
|
||||
then(function () {
|
||||
setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
}).
|
||||
waits(1500).
|
||||
then(function() {
|
||||
this.expects_that(bar).should_equal(2);
|
||||
var another_spec = it('spec w/ queued statments', function () {
|
||||
runs(function () {
|
||||
setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
});
|
||||
waits(500);
|
||||
runs(function () {
|
||||
setTimeout(function() {
|
||||
bar++;
|
||||
}, 250);
|
||||
});
|
||||
waits(1500)
|
||||
runs(function() {
|
||||
this.expects_that(bar).should_equal(2);
|
||||
});
|
||||
});
|
||||
|
||||
var mockSuite = {
|
||||
@@ -481,14 +493,14 @@ var testSpecScope = function () {
|
||||
|
||||
var testRunner = function() {
|
||||
|
||||
var runner = Jasmine();
|
||||
var runner = Runner();
|
||||
describe('one suite description', function () {
|
||||
it('should be a test');
|
||||
});
|
||||
reporter.test((runner.suites.length === 1),
|
||||
"Runner expected one suite");
|
||||
|
||||
runner = Jasmine();
|
||||
runner = Runner();
|
||||
describe('one suite description', function () {
|
||||
it('should be a test');
|
||||
});
|
||||
@@ -498,7 +510,7 @@ var testRunner = function() {
|
||||
reporter.test((runner.suites.length === 2),
|
||||
"Runner expected two suites");
|
||||
|
||||
runner = Jasmine();
|
||||
runner = Runner();
|
||||
describe('one suite description', function () {
|
||||
it('should be a test', function() {
|
||||
runs(function () {
|
||||
@@ -578,7 +590,7 @@ var testNestedResults = function () {
|
||||
}
|
||||
|
||||
var testReporting = function () {
|
||||
var runner = Jasmine();
|
||||
var runner = Runner();
|
||||
describe('one suite description', function () {
|
||||
it('should be a test', function() {
|
||||
runs(function () {
|
||||
@@ -628,7 +640,7 @@ var runTests = function () {
|
||||
setTimeout(function() {
|
||||
$('spinner').hide();
|
||||
reporter.summary();
|
||||
}, 4500);
|
||||
}, 3500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BIN
test/spinner.gif
BIN
test/spinner.gif
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB |
@@ -1,23 +0,0 @@
|
||||
<!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>
|
||||
<link type="text/css" rel="stylesheet" href="test.css"/>
|
||||
<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>
|
||||
|
||||
|
||||
126
test/test.js
126
test/test.js
@@ -1,126 +0,0 @@
|
||||
// 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();
|
||||
});
|
||||
|
||||
it('should support should_not_equal() passing', function () {
|
||||
Jasmine = jasmine_init();
|
||||
|
||||
expects(true).should_not_equal(false);
|
||||
|
||||
var expected_message = 'Passed.';
|
||||
expects_that(Jasmine.results[0].message).should_equal(expected_message).and_finish();
|
||||
});
|
||||
|
||||
it('should support should_not_equal() message', function () {
|
||||
Jasmine = jasmine_init();
|
||||
|
||||
expects(true).should_not_equal(true);
|
||||
|
||||
var expected_message = 'Expected true to not equal true, but it does.';
|
||||
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('can have multiple assertions', function () {
|
||||
Jasmine = jasmine_init();
|
||||
|
||||
var a_spec = spec('new spec', function () {
|
||||
var foo = 'bar';
|
||||
var baz = 'quux'
|
||||
|
||||
expects(foo).should_equal('bar');
|
||||
expects(baz).should_equal('quux');
|
||||
});
|
||||
|
||||
a_spec.execute();
|
||||
|
||||
expects_that(Jasmine.results.length).should_equal(2).and_finish();
|
||||
});
|
||||
|
||||
// it('can evaluate expectations after an asynchronous set of execution steps', function () {
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
// should be able to run multiple specs in a suite in order
|
||||
|
||||
//with(JSpec('Test runner')) {
|
||||
//
|
||||
// it('should run a test and collect a result', function () {
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// });
|
||||
//
|
||||
// expects_that(actual).should_equal(expected)u;
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
Reference in New Issue
Block a user