Merge branch 'beforeall-in-xdescribe' of https://github.com/voithos/jasmine into voithos-beforeall-in-xdescribe

- Merges #1225 from @voithos
- Fixes #1175
This commit is contained in:
Gregg Van Hove
2016-12-02 09:47:01 -08:00
6 changed files with 30 additions and 41 deletions
+2 -11
View File
@@ -766,7 +766,7 @@ getJasmineRequireObj().Env = function(j$) {
reporter.suiteStarted(suite.result); reporter.suiteStarted(suite.result);
}, },
nodeComplete: function(suite, result) { nodeComplete: function(suite, result) {
if (!suite.disabled) { if (!suite.markedPending) {
clearResourcesForRunnable(suite.id); clearResourcesForRunnable(suite.id);
} }
currentlyExecutingSuites.pop(); currentlyExecutingSuites.pop();
@@ -2417,7 +2417,6 @@ getJasmineRequireObj().Suite = function(j$) {
this.afterFns = []; this.afterFns = [];
this.beforeAllFns = []; this.beforeAllFns = [];
this.afterAllFns = []; this.afterAllFns = [];
this.disabled = false;
this.children = []; this.children = [];
@@ -2443,10 +2442,6 @@ getJasmineRequireObj().Suite = function(j$) {
return fullName.join(' '); return fullName.join(' ');
}; };
Suite.prototype.disable = function() {
this.disabled = true;
};
Suite.prototype.pend = function(message) { Suite.prototype.pend = function(message) {
this.markedPending = true; this.markedPending = true;
}; };
@@ -2472,10 +2467,6 @@ getJasmineRequireObj().Suite = function(j$) {
}; };
Suite.prototype.status = function() { Suite.prototype.status = function() {
if (this.disabled) {
return 'disabled';
}
if (this.markedPending) { if (this.markedPending) {
return 'pending'; return 'pending';
} }
@@ -2488,7 +2479,7 @@ getJasmineRequireObj().Suite = function(j$) {
}; };
Suite.prototype.isExecutable = function() { Suite.prototype.isExecutable = function() {
return !this.disabled; return !this.markedPending;
}; };
Suite.prototype.canBeReentered = function() { Suite.prototype.canBeReentered = function() {
+3 -18
View File
@@ -83,13 +83,6 @@ describe("Suite", function() {
expect(suite.getResult().status).toBe('finished'); expect(suite.getResult().status).toBe('finished');
}); });
it("retrieves a result with disabled status", function() {
var suite = new jasmineUnderTest.Suite({});
suite.disable();
expect(suite.getResult().status).toBe('disabled');
});
it("retrieves a result with pending status", function() { it("retrieves a result with pending status", function() {
var suite = new jasmineUnderTest.Suite({}); var suite = new jasmineUnderTest.Suite({});
suite.pend(); suite.pend();
@@ -97,23 +90,15 @@ describe("Suite", function() {
expect(suite.getResult().status).toBe('pending'); expect(suite.getResult().status).toBe('pending');
}); });
it("priviledges a disabled status over pending status", function() { it("is executable if not pending", function() {
var suite = new jasmineUnderTest.Suite({});
suite.disable();
suite.pend();
expect(suite.getResult().status).toBe('disabled');
});
it("is executable if not disabled", function() {
var suite = new jasmineUnderTest.Suite({}); var suite = new jasmineUnderTest.Suite({});
expect(suite.isExecutable()).toBe(true); expect(suite.isExecutable()).toBe(true);
}); });
it("is not executable if disabled", function() { it("is not executable if pending", function() {
var suite = new jasmineUnderTest.Suite({}); var suite = new jasmineUnderTest.Suite({});
suite.disable(); suite.pend();
expect(suite.isExecutable()).toBe(false); expect(suite.isExecutable()).toBe(false);
}); });
+1 -1
View File
@@ -1425,7 +1425,7 @@ describe("Env integration", function() {
totalSpecsDefined: 1 totalSpecsDefined: 1
}); });
expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'pending' })); expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'disabled' }));
expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({ description: 'xd out', status: 'pending' })); expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({ description: 'xd out', status: 'pending' }));
expect(reporter.suiteDone.calls.count()).toBe(4); expect(reporter.suiteDone.calls.count()).toBe(4);
+22
View File
@@ -518,6 +518,28 @@ describe("jasmine spec running", function () {
env.execute(); env.execute();
}); });
it("shouldn't run before/after functions in disabled suites", function(done) {
var shouldNotRun = jasmine.createSpy("shouldNotRun"),
suite = env.xdescribe('A disabled Suite', function() {
// None of the before/after functions should run.
env.beforeAll(shouldNotRun);
env.beforeEach(shouldNotRun);
env.afterEach(shouldNotRun);
env.afterAll(shouldNotRun);
env.it('spec inside a disabled suite', shouldNotRun);
});
var assertions = function() {
expect(shouldNotRun).not.toHaveBeenCalled();
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
it("should allow top level suites to be disabled", function(done) { it("should allow top level suites to be disabled", function(done) {
var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"), var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),
otherSpec = jasmine.createSpy("otherSpec"); otherSpec = jasmine.createSpy("otherSpec");
+1 -1
View File
@@ -229,7 +229,7 @@ getJasmineRequireObj().Env = function(j$) {
reporter.suiteStarted(suite.result); reporter.suiteStarted(suite.result);
}, },
nodeComplete: function(suite, result) { nodeComplete: function(suite, result) {
if (!suite.disabled) { if (!suite.markedPending) {
clearResourcesForRunnable(suite.id); clearResourcesForRunnable(suite.id);
} }
currentlyExecutingSuites.pop(); currentlyExecutingSuites.pop();
+1 -10
View File
@@ -12,7 +12,6 @@ getJasmineRequireObj().Suite = function(j$) {
this.afterFns = []; this.afterFns = [];
this.beforeAllFns = []; this.beforeAllFns = [];
this.afterAllFns = []; this.afterAllFns = [];
this.disabled = false;
this.children = []; this.children = [];
@@ -38,10 +37,6 @@ getJasmineRequireObj().Suite = function(j$) {
return fullName.join(' '); return fullName.join(' ');
}; };
Suite.prototype.disable = function() {
this.disabled = true;
};
Suite.prototype.pend = function(message) { Suite.prototype.pend = function(message) {
this.markedPending = true; this.markedPending = true;
}; };
@@ -67,10 +62,6 @@ getJasmineRequireObj().Suite = function(j$) {
}; };
Suite.prototype.status = function() { Suite.prototype.status = function() {
if (this.disabled) {
return 'disabled';
}
if (this.markedPending) { if (this.markedPending) {
return 'pending'; return 'pending';
} }
@@ -83,7 +74,7 @@ getJasmineRequireObj().Suite = function(j$) {
}; };
Suite.prototype.isExecutable = function() { Suite.prototype.isExecutable = function() {
return !this.disabled; return !this.markedPending;
}; };
Suite.prototype.canBeReentered = function() { Suite.prototype.canBeReentered = function() {