Last commit did not include self-test with Any and ObjectContaining in separate files. Fixed.

This commit is contained in:
Davis W. Frank
2013-06-02 22:16:30 -07:00
parent 475aacbfbb
commit 3271dc8838
7 changed files with 627 additions and 460 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -13,19 +13,19 @@ describe("ObjectContaining", function() {
});
it("matches when the key/value pair is present in the actual", function() {
var containing = new jasmine.Matchers.ObjectContaining({foo: "fooVal"});
var containing = new j$.ObjectContaining({foo: "fooVal"});
expect(containing.jasmineMatches({foo: "fooVal", bar: "barVal"})).toBe(true);
});
it("does not match when the key/value pair is not present in the actual", function() {
var containing = new jasmine.Matchers.ObjectContaining({foo: "fooVal"});
var containing = new j$.ObjectContaining({foo: "fooVal"});
expect(containing.jasmineMatches({bar: "barVal", quux: "quuxVal"})).toBe(false);
});
it("does not match when the key is present but the value is different in the actual", function() {
var containing = new jasmine.Matchers.ObjectContaining({foo: "other"});
var containing = new j$.ObjectContaining({foo: "other"});
expect(containing.jasmineMatches({foo: "fooVal", bar: "barVal"})).toBe(false);
});

View File

@@ -52,7 +52,7 @@ describe('Spies', function () {
var TestClass = {
someFunction: function() {
originalFunctionWasCalled = true;
passedArgs = arguments;
passedArgs = Array.prototype.slice.call(arguments, 0);
passedObj = this;
return "return value from original function";
}
@@ -117,7 +117,7 @@ describe('Spies', function () {
env.spyOn(TestClass, 'someFunction').andCallFake(function() {
fakeFunctionWasCalled = true;
passedArgs = arguments;
passedArgs = Array.prototype.slice.call(arguments, 0);
passedObj = this;
return "return value from fake function";
});
@@ -185,7 +185,6 @@ describe('Spies', function () {
expect(exception).toBeDefined();
});
it('to spy on an undefined method throws exception', function() {
var TestClass = {
someFunction : function() {
@@ -193,11 +192,11 @@ describe('Spies', function () {
};
function efunc() {
env.spyOn(TestClass, 'someOtherFunction');
};
}
expect(function() {
efunc();
}).toThrow('someOtherFunction() method does not exist');
});
it('should be able to reset a spy', function() {
@@ -214,7 +213,8 @@ describe('Spies', function () {
describe("createSpyObj", function() {
it("should create an object with a bunch of spy methods when you call jasmine.createSpyObj()", function() {
var spyObj = jasmine.createSpyObj('BaseName', ['method1', 'method2']);
var spyObj = j$.createSpyObj('BaseName', ['method1', 'method2']);
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
expect(spyObj.method1.identity).toEqual('BaseName.method1');
expect(spyObj.method2.identity).toEqual('BaseName.method2');
@@ -222,15 +222,8 @@ describe('Spies', function () {
it("should throw if you do not pass an array argument", function() {
expect(function() {
jasmine.createSpyObj('BaseName');
}).toThrow('createSpyObj requires a non-empty array of method names to create spies for');
});
it("should throw if you pass an empty array argument", function() {
expect(function() {
jasmine.createSpyObj('BaseName');
}).toThrow('createSpyObj requires a non-empty array of method names to create spies for');
j$.createSpyObj('BaseName');
}).toThrow("createSpyObj requires a non-empty array of method names to create spies for");
});
});
});

View File

@@ -2,7 +2,7 @@ describe("MatchersSpec - HTML Dependent", function () {
var env, spec;
beforeEach(function() {
env = new jasmine.Env();
env = new j$.Env();
env.updateInterval = 0;
var suite = env.describe("suite", function() {
@@ -29,7 +29,7 @@ describe("MatchersSpec - HTML Dependent", function () {
return spec.addExpectationResult.mostRecentCall.args[1];
}
it("toEqual with DOM nodes", function() {
xit("toEqual with DOM nodes", function() {
var nodeA = document.createElement('div');
var nodeB = document.createElement('div');
expect((match(nodeA).toEqual(nodeA))).toPass();

View File

@@ -326,7 +326,7 @@ getJasmineRequireObj().Env = function(j$) {
// TODO: move this to closure
Env.prototype.pending = function() {
throw new Error(j$.Spec.pendingSpecExceptionMessage);
throw j$.Spec.pendingSpecExceptionMessage;
};
// TODO: Still needed?

View File

@@ -29,4 +29,4 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
};
return ObjectContaining;
};
};

View File

@@ -48,11 +48,11 @@ getJasmineRequireObj().base = function(j$) {
};
j$.any = function(clazz) {
return new j$.Matchers.Any(clazz);
return new j$.Any(clazz);
};
j$.objectContaining = function(sample) {
return new j$.Matchers.ObjectContaining(sample);
return new j$.ObjectContaining(sample);
};
j$.Spy = function(name) {
@@ -128,7 +128,7 @@ getJasmineRequireObj().base = function(j$) {
j$.createSpyObj = function(baseName, methodNames) {
if (!j$.isArray_(methodNames) || methodNames.length === 0) {
throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
throw "createSpyObj requires a non-empty array of method names to create spies for";
}
var obj = {};
for (var i = 0; i < methodNames.length; i++) {