specs() refactor, added test coverage

This commit is contained in:
ragaskar
2009-09-02 07:30:31 -07:00
parent 50134eb1ac
commit 4533d6a7cd
20 changed files with 107 additions and 70 deletions

View File

@@ -12,54 +12,91 @@ describe('Suite', function() {
env.clearInterval = fakeTimer.clearInterval;
});
it('should keep a count of the number of specs that are run' , function() {
env.describe('one suite description', function () {
env.it('should be a test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
env.it('should be another test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
env.it('should be a third test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
describe('Specs', function () {
it('#specs should return all immediate children that are specs.', function () {
var suite =env.describe('Suite 1', function () {
env.it('Spec 1', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
env.it('Spec 2', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
env.describe('Suite 2', function () {
env.it('Spec 3', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
});
env.it('Spec 4', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
});
var suiteSpecs = suite.specs();
expect(suiteSpecs.length).toEqual(3);
expect(suiteSpecs[0].description).toEqual('Spec 1');
expect(suiteSpecs[1].description).toEqual('Spec 2');
expect(suiteSpecs[2].description).toEqual('Spec 4');
});
var suite = env.currentRunner.suites[0];
expect(suite.specCount()).toEqual(3);
});
describe('SpecCount', function () {
it('specCount should be correct even with runs/waits blocks' , function() {
env.describe('one suite description', function () {
env.it('should be a test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
it('should keep a count of the number of specs that are run', function() {
env.describe('one suite description', function () {
env.it('should be a test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
env.it('should be another test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
env.it('should be a third test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
});
var suite = env.currentRunner.suites[0];
expect(suite.specCount()).toEqual(3);
});
env.it('should be another test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
this.waits(10);
this.runs(function () {
this.expect(true).toEqual(true);
});
});
env.it('should be a third test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
it('specCount should be correct even with runs/waits blocks', function() {
env.describe('one suite description', function () {
env.it('should be a test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
env.it('should be another test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
this.waits(10);
this.runs(function () {
this.expect(true).toEqual(true);
});
});
env.it('should be a third test', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
});
var suite = env.currentRunner.suites[0];
expect(suite.specCount()).toEqual(3);
});
});
var suite = env.currentRunner.suites[0];
expect(suite.specCount()).toEqual(3);
});
});