2009-08-27 21:21:10 +00:00
|
|
|
describe('Suite', function() {
|
|
|
|
var fakeTimer;
|
|
|
|
var env;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
env = new jasmine.Env();
|
2009-10-06 05:36:10 +00:00
|
|
|
env.updateInterval = 0;
|
2009-08-27 21:21:10 +00:00
|
|
|
|
|
|
|
fakeTimer = new jasmine.FakeTimer();
|
|
|
|
env.setTimeout = fakeTimer.setTimeout;
|
|
|
|
env.clearTimeout = fakeTimer.clearTimeout;
|
|
|
|
env.setInterval = fakeTimer.setInterval;
|
|
|
|
env.clearInterval = fakeTimer.clearInterval;
|
|
|
|
});
|
|
|
|
|
2009-09-02 14:30:31 +00:00
|
|
|
describe('Specs', function () {
|
2010-06-22 17:18:22 +00:00
|
|
|
var suite;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
suite = env.describe('Suite 1', function () {
|
2009-09-02 14:30:31 +00:00
|
|
|
env.it('Spec 1', function() {
|
|
|
|
this.runs(function () {
|
|
|
|
this.expect(true).toEqual(true);
|
|
|
|
});
|
2009-08-27 21:21:10 +00:00
|
|
|
});
|
2009-09-02 14:30:31 +00:00
|
|
|
env.it('Spec 2', function() {
|
|
|
|
this.runs(function () {
|
|
|
|
this.expect(true).toEqual(true);
|
|
|
|
});
|
2009-08-27 21:21:10 +00:00
|
|
|
});
|
2009-09-02 14:30:31 +00:00
|
|
|
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);
|
|
|
|
});
|
2009-08-27 21:21:10 +00:00
|
|
|
});
|
|
|
|
});
|
2010-06-22 17:18:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('#specs should return all immediate children that are specs.', function () {
|
2009-09-02 14:30:31 +00:00
|
|
|
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');
|
2009-08-27 21:21:10 +00:00
|
|
|
});
|
|
|
|
|
2010-06-22 17:18:22 +00:00
|
|
|
it("#suites should return all immediate children that are suites.", function() {
|
|
|
|
var nestedSuites = suite.suites();
|
|
|
|
expect(nestedSuites.length).toEqual(1);
|
|
|
|
expect(nestedSuites[0].description).toEqual('Suite 2');
|
|
|
|
});
|
2009-08-27 21:21:10 +00:00
|
|
|
|
2010-06-22 17:18:22 +00:00
|
|
|
it("#children should return all immediate children including suites and specs.", function() {
|
|
|
|
var children = suite.children();
|
|
|
|
expect(children.length).toEqual(4);
|
|
|
|
expect(children[0].description).toEqual('Spec 1');
|
|
|
|
expect(children[1].description).toEqual('Spec 2');
|
|
|
|
expect(children[2].description).toEqual('Suite 2');
|
|
|
|
expect(children[3].description).toEqual('Spec 4');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-06-07 14:01:48 +00:00
|
|
|
describe('getFullName', function() {
|
|
|
|
describe('with class', function() {
|
|
|
|
function MyClass() {}
|
|
|
|
|
|
|
|
it('should use the name of the class if provided as the description', function() {
|
|
|
|
suite = env.describe(MyClass, function() {
|
|
|
|
env.it('should be something', function() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(suite.getFullName()).toEqual("MyClass");
|
|
|
|
expect(suite.children()[0].getFullName()).toEqual("MyClass should be something.");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2010-06-22 17:18:22 +00:00
|
|
|
describe('SpecCount', function () {
|
|
|
|
|
|
|
|
it('should keep a count of the number of specs that are run', function() {
|
|
|
|
var suite = env.describe('one suite description', function () {
|
|
|
|
env.it('should be a test', function() {
|
|
|
|
this.runs(function () {
|
|
|
|
this.expect(true).toEqual(true);
|
2009-09-02 14:30:31 +00:00
|
|
|
});
|
2010-06-22 17:18:22 +00:00
|
|
|
});
|
|
|
|
env.it('should be another test', function() {
|
|
|
|
this.runs(function () {
|
|
|
|
this.expect(true).toEqual(true);
|
2009-09-02 14:30:31 +00:00
|
|
|
});
|
2010-06-22 17:18:22 +00:00
|
|
|
});
|
|
|
|
env.it('should be a third test', function() {
|
|
|
|
this.runs(function () {
|
|
|
|
this.expect(true).toEqual(true);
|
2009-09-02 14:30:31 +00:00
|
|
|
});
|
2009-08-27 21:21:10 +00:00
|
|
|
});
|
|
|
|
});
|
2009-09-02 14:30:31 +00:00
|
|
|
|
2010-06-22 17:18:22 +00:00
|
|
|
expect(suite.specs().length).toEqual(3);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('specCount should be correct even with runs/waits blocks', function() {
|
|
|
|
var suite = env.describe('one suite description', function () {
|
|
|
|
env.it('should be a test', function() {
|
|
|
|
this.runs(function () {
|
|
|
|
this.expect(true).toEqual(true);
|
2009-09-02 14:30:31 +00:00
|
|
|
});
|
2010-06-22 17:18:22 +00:00
|
|
|
});
|
|
|
|
env.it('should be another test', function() {
|
|
|
|
this.runs(function () {
|
|
|
|
this.expect(true).toEqual(true);
|
2009-09-02 14:30:31 +00:00
|
|
|
});
|
2010-06-22 17:18:22 +00:00
|
|
|
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);
|
2009-09-02 14:30:31 +00:00
|
|
|
});
|
2009-08-27 21:21:10 +00:00
|
|
|
});
|
|
|
|
});
|
2010-06-22 17:18:22 +00:00
|
|
|
|
|
|
|
expect(suite.specs().length).toEqual(3);
|
2009-08-27 21:21:10 +00:00
|
|
|
});
|
|
|
|
});
|
2011-06-07 14:01:48 +00:00
|
|
|
});
|