jasmine/spec/suites/SuiteSpec.js

101 lines
3.0 KiB
JavaScript
Raw Normal View History

describe('Suite', function() {
var fakeTimer;
var env;
beforeEach(function() {
env = new jasmine.Env();
env.updateInterval = 0;
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 () {
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);
});
});
2009-09-02 14:30:31 +00:00
env.it('Spec 2', function() {
this.runs(function () {
this.expect(true).toEqual(true);
});
});
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-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-09-02 14:30:31 +00:00
describe('SpecCount', function () {
2009-09-02 14:30:31 +00:00
it('should keep a count of the number of specs that are run', function() {
2009-09-02 14:52:11 +00:00
var suite = env.describe('one suite description', function () {
2009-09-02 14:30:31 +00:00
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);
});
});
});
2009-09-02 14:30:31 +00:00
2009-10-20 00:53:29 +00:00
expect(suite.specs().length).toEqual(3);
});
2009-09-02 14:30:31 +00:00
it('specCount should be correct even with runs/waits blocks', function() {
2009-09-02 14:52:11 +00:00
var suite = env.describe('one suite description', function () {
2009-09-02 14:30:31 +00:00
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);
});
});
});
2009-09-02 14:30:31 +00:00
2009-10-20 00:53:29 +00:00
expect(suite.specs().length).toEqual(3);
});
});
});
});