first (naive) pass at beforeAll/afterAll

This commit is contained in:
Gregg Van Hove and Sheel Choksi
2014-03-03 09:26:39 -08:00
parent 9d1e92f5e2
commit ec5695acc1
5 changed files with 209 additions and 7 deletions
+71
View File
@@ -165,6 +165,77 @@ describe("Env integration", function() {
env.execute();
});
it("calls associated beforeAlls/afterAlls only once per suite", function(done) {
var env = new j$.Env(),
before = jasmine.createSpy('beforeAll'),
after = jasmine.createSpy('afterAll');
env.addReporter({
jasmineDone: function() {
expect(after).toHaveBeenCalled();
expect(after.calls.count()).toBe(1);
expect(before.calls.count()).toBe(1);
done();
}
});
env.describe("with beforeAll and afterAll", function() {
env.it("spec", function() {
expect(before).toHaveBeenCalled();
expect(after).not.toHaveBeenCalled();
});
env.it("another spec", function() {
expect(before).toHaveBeenCalled();
expect(after).not.toHaveBeenCalled();
});
env.beforeAll(before);
env.afterAll(after);
});
env.execute();
});
it("calls associated beforeAlls/afterAlls only once per suite for async", function(done) {
var env = new j$.Env(),
before = jasmine.createSpy('beforeAll'),
after = jasmine.createSpy('afterAll');
env.addReporter({
jasmineDone: function() {
expect(after).toHaveBeenCalled();
expect(after.calls.count()).toBe(1);
expect(before.calls.count()).toBe(1);
done();
}
});
env.describe("with beforeAll and afterAll", function() {
env.it("spec", function() {
expect(before).toHaveBeenCalled();
expect(after).not.toHaveBeenCalled();
});
env.it("another spec", function() {
expect(before).toHaveBeenCalled();
expect(after).not.toHaveBeenCalled();
});
env.beforeAll(function(beforeCallbackUnderTest) {
before();
beforeCallbackUnderTest();
});
env.afterAll(function(afterCallbackUnderTest) {
after();
afterCallbackUnderTest();
});
});
env.execute();
});
it("Allows specifying which specs and suites to run", function(done) {
var env = new j$.Env(),
calls = [],