Clean up a bunch of spec global variable leaks
Also some formatting changes to highlight when using one 'var' with comma operator
This commit is contained in:
@@ -14,7 +14,7 @@ describe("DelayedFunctionScheduler", function() {
|
|||||||
|
|
||||||
it("schedules a string for later execution", function() {
|
it("schedules a string for later execution", function() {
|
||||||
var scheduler = new j$.DelayedFunctionScheduler(),
|
var scheduler = new j$.DelayedFunctionScheduler(),
|
||||||
strfn = "horrible = true;";
|
strfn = "horrible = true;";
|
||||||
|
|
||||||
scheduler.scheduleFunction(strfn, 0);
|
scheduler.scheduleFunction(strfn, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -6,20 +6,20 @@ describe("Env", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('removes all spies when env is executed', function(done) {
|
it('removes all spies when env is executed', function(done) {
|
||||||
originalFoo = function() {},
|
var originalFoo = function() {},
|
||||||
testObj = {
|
testObj = {
|
||||||
foo: originalFoo
|
foo: originalFoo
|
||||||
},
|
},
|
||||||
firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() {
|
firstSpec = jasmine.createSpy('firstSpec').and.callFake(function() {
|
||||||
env.spyOn(testObj, 'foo');
|
env.spyOn(testObj, 'foo');
|
||||||
}),
|
}),
|
||||||
secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() {
|
secondSpec = jasmine.createSpy('secondSpec').and.callFake(function() {
|
||||||
expect(testObj.foo).toBe(originalFoo);
|
expect(testObj.foo).toBe(originalFoo);
|
||||||
});
|
});
|
||||||
env.describe('test suite', function() {
|
env.describe('test suite', function() {
|
||||||
env.it('spec 0', firstSpec);
|
env.it('spec 0', firstSpec);
|
||||||
env.it('spec 1', secondSpec);
|
env.it('spec 1', secondSpec);
|
||||||
});
|
});
|
||||||
|
|
||||||
var assertions = function() {
|
var assertions = function() {
|
||||||
expect(firstSpec).toHaveBeenCalled();
|
expect(firstSpec).toHaveBeenCalled();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ describe('Exceptions:', function() {
|
|||||||
env.it('should be a passing test that runs after exceptions are thrown from a async test', secondTest);
|
env.it('should be a passing test that runs after exceptions are thrown from a async test', secondTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
expectations = function() {
|
var expectations = function() {
|
||||||
expect(secondTest).toHaveBeenCalled();
|
expect(secondTest).toHaveBeenCalled();
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
@@ -55,7 +55,7 @@ describe('Exceptions:', function() {
|
|||||||
});
|
});
|
||||||
env.describe("a suite that doesn't throw an exception", secondDescribe);
|
env.describe("a suite that doesn't throw an exception", secondDescribe);
|
||||||
|
|
||||||
expectations = function() {
|
var expectations = function() {
|
||||||
expect(secondDescribe).toHaveBeenCalled();
|
expect(secondDescribe).toHaveBeenCalled();
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,31 +50,31 @@ describe("QueueRunner", function() {
|
|||||||
//createSpy('asyncfn').and.callFake(function(done) {});
|
//createSpy('asyncfn').and.callFake(function(done) {});
|
||||||
|
|
||||||
var onComplete = jasmine.createSpy('onComplete'),
|
var onComplete = jasmine.createSpy('onComplete'),
|
||||||
beforeCallback = jasmine.createSpy('beforeCallback'),
|
beforeCallback = jasmine.createSpy('beforeCallback'),
|
||||||
fnCallback = jasmine.createSpy('fnCallback'),
|
fnCallback = jasmine.createSpy('fnCallback'),
|
||||||
afterCallback = jasmine.createSpy('afterCallback'),
|
afterCallback = jasmine.createSpy('afterCallback'),
|
||||||
fn1 = function(done) {
|
fn1 = function(done) {
|
||||||
beforeCallback();
|
beforeCallback();
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
done()
|
done()
|
||||||
}, 100);
|
}, 100);
|
||||||
},
|
},
|
||||||
fn2 = function(done) {
|
fn2 = function(done) {
|
||||||
fnCallback();
|
fnCallback();
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
done()
|
done()
|
||||||
}, 100);
|
}, 100);
|
||||||
},
|
},
|
||||||
fn3 = function(done) {
|
fn3 = function(done) {
|
||||||
afterCallback();
|
afterCallback();
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
done()
|
done()
|
||||||
}, 100);
|
}, 100);
|
||||||
},
|
},
|
||||||
queueRunner = new j$.QueueRunner({
|
queueRunner = new j$.QueueRunner({
|
||||||
fns: [fn1, fn2, fn3],
|
fns: [fn1, fn2, fn3],
|
||||||
onComplete: onComplete
|
onComplete: onComplete
|
||||||
});
|
});
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
|
|
||||||
@@ -129,11 +129,10 @@ describe("QueueRunner", function() {
|
|||||||
|
|
||||||
it("continues running the functions even after an exception is thrown in an async spec", function() {
|
it("continues running the functions even after an exception is thrown in an async spec", function() {
|
||||||
var fn = function(done) { throw new Error("error"); },
|
var fn = function(done) { throw new Error("error"); },
|
||||||
nextFn = jasmine.createSpy("nextFunction");
|
nextFn = jasmine.createSpy("nextFunction"),
|
||||||
|
queueRunner = new j$.QueueRunner({
|
||||||
queueRunner = new j$.QueueRunner({
|
fns: [fn, nextFn]
|
||||||
fns: [fn, nextFn]
|
});
|
||||||
});
|
|
||||||
|
|
||||||
queueRunner.execute();
|
queueRunner.execute();
|
||||||
expect(nextFn).toHaveBeenCalled();
|
expect(nextFn).toHaveBeenCalled();
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ describe("toBeGreaterThan", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when actual <= expected", function() {
|
it("fails when actual <= expected", function() {
|
||||||
var matcher = j$.matchers.toBeGreaterThan();
|
var matcher = j$.matchers.toBeGreaterThan(),
|
||||||
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 1);
|
result = matcher.compare(1, 1);
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ describe("toBeNaN", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails for anything not a NaN", function() {
|
it("fails for anything not a NaN", function() {
|
||||||
var matcher = j$.matchers.toBeNaN();
|
var matcher = j$.matchers.toBeNaN(),
|
||||||
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1);
|
result = matcher.compare(1);
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ describe("toBeUndefined", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when matching defined values", function() {
|
it("fails when matching defined values", function() {
|
||||||
var matcher = j$.matchers.toBeUndefined();
|
var matcher = j$.matchers.toBeUndefined(),
|
||||||
|
result;
|
||||||
|
|
||||||
result = matcher.compare('foo');
|
result = matcher.compare('foo');
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ describe("toContain", function() {
|
|||||||
var util = {
|
var util = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = j$.matchers.toContain(util);
|
matcher = j$.matchers.toContain(util),
|
||||||
|
result;
|
||||||
|
|
||||||
result = matcher.compare("ABC", "B");
|
result = matcher.compare("ABC", "B");
|
||||||
expect(util.contains).toHaveBeenCalledWith("ABC", "B", []);
|
expect(util.contains).toHaveBeenCalledWith("ABC", "B", []);
|
||||||
@@ -15,7 +16,8 @@ describe("toContain", function() {
|
|||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
||||||
},
|
},
|
||||||
customEqualityTesters = ['a', 'b'],
|
customEqualityTesters = ['a', 'b'],
|
||||||
matcher = j$.matchers.toContain(util, customEqualityTesters);
|
matcher = j$.matchers.toContain(util, customEqualityTesters),
|
||||||
|
result;
|
||||||
|
|
||||||
result = matcher.compare("ABC", "B");
|
result = matcher.compare("ABC", "B");
|
||||||
expect(util.contains).toHaveBeenCalledWith("ABC", "B", ['a', 'b']);
|
expect(util.contains).toHaveBeenCalledWith("ABC", "B", ['a', 'b']);
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ describe("toHaveBeenCalled", function() {
|
|||||||
|
|
||||||
it("fails when the actual was not called", function() {
|
it("fails when the actual was not called", function() {
|
||||||
var matcher = j$.matchers.toHaveBeenCalled(),
|
var matcher = j$.matchers.toHaveBeenCalled(),
|
||||||
uncalledSpy = j$.createSpy('uncalled spy');
|
uncalledSpy = j$.createSpy('uncalled spy'),
|
||||||
|
result;
|
||||||
|
|
||||||
result = matcher.compare(uncalledSpy);
|
result = matcher.compare(uncalledSpy);
|
||||||
expect(result.pass).toBe(false);
|
expect(result.pass).toBe(false);
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ describe("New HtmlReporter", function() {
|
|||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new j$.Env();
|
||||||
container = document.createElement("div");
|
container = document.createElement("div");
|
||||||
getContainer = function() { return container; },
|
var getContainer = function() { return container; },
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new j$.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
@@ -377,13 +377,13 @@ describe("New HtmlReporter", function() {
|
|||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new j$.Env();
|
||||||
container = document.createElement("div");
|
container = document.createElement("div");
|
||||||
getContainer = function() { return container; },
|
var getContainer = function() { return container; };
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new j$.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||||
});
|
});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
reporter.jasmineStarted({});
|
reporter.jasmineStarted({});
|
||||||
@@ -414,14 +414,14 @@ describe("New HtmlReporter", function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
env = new j$.Env();
|
env = new j$.Env();
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div");
|
||||||
getContainer = function() { return container; },
|
var getContainer = function() { return container; }
|
||||||
reporter = new j$.HtmlReporter({
|
reporter = new j$.HtmlReporter({
|
||||||
env: env,
|
env: env,
|
||||||
getContainer: getContainer,
|
getContainer: getContainer,
|
||||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||||
});
|
});
|
||||||
reporter.initialize();
|
reporter.initialize();
|
||||||
|
|
||||||
reporter.jasmineStarted({});
|
reporter.jasmineStarted({});
|
||||||
|
|||||||
Reference in New Issue
Block a user