Generate combined file for previous features

This commit is contained in:
Gregg Van Hove
2016-03-26 21:27:04 -07:00
parent 954a6a0091
commit 6c0224414c

View File

@@ -47,6 +47,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
jRequire.base(j$, jasmineGlobal); jRequire.base(j$, jasmineGlobal);
j$.util = jRequire.util(); j$.util = jRequire.util();
j$.errors = jRequire.errors(); j$.errors = jRequire.errors();
j$.formatErrorMsg = jRequire.formatErrorMsg();
j$.Any = jRequire.Any(j$); j$.Any = jRequire.Any(j$);
j$.Anything = jRequire.Anything(j$); j$.Anything = jRequire.Anything(j$);
j$.CallTracker = jRequire.CallTracker(j$); j$.CallTracker = jRequire.CallTracker(j$);
@@ -1890,6 +1891,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
called = true; called = true;
fn(); fn();
} }
return null;
}; };
} }
@@ -2033,6 +2035,8 @@ getJasmineRequireObj().ReportDispatcher = function() {
getJasmineRequireObj().SpyRegistry = function(j$) { getJasmineRequireObj().SpyRegistry = function(j$) {
var getErrorMsg = j$.formatErrorMsg('<spyOn>', 'spyOn(<object>, <methodName>)');
function SpyRegistry(options) { function SpyRegistry(options) {
options = options || {}; options = options || {};
var currentSpies = options.currentSpies || function() { return []; }; var currentSpies = options.currentSpies || function() { return []; };
@@ -2042,23 +2046,24 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
}; };
this.spyOn = function(obj, methodName) { this.spyOn = function(obj, methodName) {
if (j$.util.isUndefined(obj)) { if (j$.util.isUndefined(obj)) {
throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()'); throw new Error(getErrorMsg('could not find an object to spy upon for ' + methodName + '()'));
} }
if (j$.util.isUndefined(methodName)) { if (j$.util.isUndefined(methodName)) {
throw new Error('No method name supplied'); throw new Error(getErrorMsg('No method name supplied'));
} }
if (j$.util.isUndefined(obj[methodName])) { if (j$.util.isUndefined(obj[methodName])) {
throw new Error(methodName + '() method does not exist'); throw new Error(getErrorMsg(methodName + '() method does not exist'));
} }
if (obj[methodName] && j$.isSpy(obj[methodName]) ) { if (obj[methodName] && j$.isSpy(obj[methodName]) ) {
if ( !!this.respy ){ if ( !!this.respy ){
return obj[methodName]; return obj[methodName];
}else { }else {
throw new Error(methodName + ' has already been spied upon'); throw new Error(getErrorMsg(methodName + ' has already been spied upon'));
} }
} }
@@ -2070,7 +2075,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
} }
if (descriptor && !(descriptor.writable || descriptor.set)) { if (descriptor && !(descriptor.writable || descriptor.set)) {
throw new Error(methodName + ' is not declared writable or has no setter'); throw new Error(getErrorMsg(methodName + ' is not declared writable or has no setter'));
} }
var originalMethod = obj[methodName], var originalMethod = obj[methodName],
@@ -2739,6 +2744,18 @@ getJasmineRequireObj().errors = function() {
ExpectationFailed: ExpectationFailed ExpectationFailed: ExpectationFailed
}; };
}; };
getJasmineRequireObj().formatErrorMsg = function() {
function generateErrorMsg(domain, usage) {
var usageDefinition = usage ? '\nUsage: ' + usage : '';
return function errorMsg(msg) {
return domain + ' : ' + msg + usageDefinition;
};
}
return generateErrorMsg;
};
getJasmineRequireObj().matchersUtil = function(j$) { getJasmineRequireObj().matchersUtil = function(j$) {
// TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter? // TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter?
@@ -3212,17 +3229,19 @@ getJasmineRequireObj().toEqual = function() {
getJasmineRequireObj().toHaveBeenCalled = function(j$) { getJasmineRequireObj().toHaveBeenCalled = function(j$) {
var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalled>', 'expect(<spyObj>).toHaveBeenCalled()');
function toHaveBeenCalled() { function toHaveBeenCalled() {
return { return {
compare: function(actual) { compare: function(actual) {
var result = {}; var result = {};
if (!j$.isSpy(actual)) { if (!j$.isSpy(actual)) {
throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.'); throw new Error(getErrorMsg('Expected a spy, but got ' + j$.pp(actual) + '.'));
} }
if (arguments.length > 1) { if (arguments.length > 1) {
throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith'); throw new Error(getErrorMsg('Does not take arguments, use toHaveBeenCalledWith'));
} }
result.pass = actual.calls.any(); result.pass = actual.calls.any();
@@ -3241,18 +3260,20 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) { getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledTimes>', 'expect(<spyObj>).toHaveBeenCalledTimes(<Number>)');
function toHaveBeenCalledTimes() { function toHaveBeenCalledTimes() {
return { return {
compare: function(actual, expected) { compare: function(actual, expected) {
if (!j$.isSpy(actual)) { if (!j$.isSpy(actual)) {
throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.'); throw new Error(getErrorMsg('Expected a spy, but got ' + j$.pp(actual) + '.'));
} }
var args = Array.prototype.slice.call(arguments, 0), var args = Array.prototype.slice.call(arguments, 0),
result = { pass: false }; result = { pass: false };
if (!j$.isNumber_(expected)){ if (!j$.isNumber_(expected)){
throw new Error('The expected times failed is a required argument and must be a number.'); throw new Error(getErrorMsg('The expected times failed is a required argument and must be a number.'));
} }
actual = args[0]; actual = args[0];
@@ -3269,8 +3290,11 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
return toHaveBeenCalledTimes; return toHaveBeenCalledTimes;
}; };
getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledWith>', 'expect(<spyObj>).toHaveBeenCalledWith(...arguments)');
function toHaveBeenCalledWith(util, customEqualityTesters) { function toHaveBeenCalledWith(util, customEqualityTesters) {
return { return {
compare: function() { compare: function() {
@@ -3280,7 +3304,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
result = { pass: false }; result = { pass: false };
if (!j$.isSpy(actual)) { if (!j$.isSpy(actual)) {
throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.'); throw new Error(getErrorMsg('Expected a spy, but got ' + j$.pp(actual) + '.'));
} }
if (!actual.calls.any()) { if (!actual.calls.any()) {
@@ -3305,11 +3329,13 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
getJasmineRequireObj().toMatch = function(j$) { getJasmineRequireObj().toMatch = function(j$) {
var getErrorMsg = j$.formatErrorMsg('<toMatch>', 'expect(<expectation>).toMatch(<string> || <regexp>)');
function toMatch() { function toMatch() {
return { return {
compare: function(actual, expected) { compare: function(actual, expected) {
if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) { if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) {
throw new Error('Expected is not a String or a RegExp'); throw new Error(getErrorMsg('Expected is not a String or a RegExp'));
} }
var regexp = new RegExp(expected); var regexp = new RegExp(expected);
@@ -3326,6 +3352,8 @@ getJasmineRequireObj().toMatch = function(j$) {
getJasmineRequireObj().toThrow = function(j$) { getJasmineRequireObj().toThrow = function(j$) {
var getErrorMsg = j$.formatErrorMsg('<toThrow>', 'expect(function() {<expectation>}).toThrow()');
function toThrow(util) { function toThrow(util) {
return { return {
compare: function(actual, expected) { compare: function(actual, expected) {
@@ -3334,7 +3362,7 @@ getJasmineRequireObj().toThrow = function(j$) {
thrown; thrown;
if (typeof actual != 'function') { if (typeof actual != 'function') {
throw new Error('Actual is not a Function'); throw new Error(getErrorMsg('Actual is not a Function'));
} }
try { try {
@@ -3372,6 +3400,9 @@ getJasmineRequireObj().toThrow = function(j$) {
}; };
getJasmineRequireObj().toThrowError = function(j$) { getJasmineRequireObj().toThrowError = function(j$) {
var getErrorMsg = j$.formatErrorMsg('<toThrowError>', 'expect(function() {<expectation>}).toThrowError(<ErrorConstructor>, <message>)');
function toThrowError () { function toThrowError () {
return { return {
compare: function(actual) { compare: function(actual) {
@@ -3381,7 +3412,7 @@ getJasmineRequireObj().toThrowError = function(j$) {
thrown; thrown;
if (typeof actual != 'function') { if (typeof actual != 'function') {
throw new Error('Actual is not a Function'); throw new Error(getErrorMsg('Actual is not a Function'));
} }
var errorMatcher = getMatcher.apply(null, arguments); var errorMatcher = getMatcher.apply(null, arguments);
@@ -3437,15 +3468,15 @@ getJasmineRequireObj().toThrowError = function(j$) {
errorType = arguments[1]; errorType = arguments[1];
expected = arguments[2]; expected = arguments[2];
if (!isAnErrorType(errorType)) { if (!isAnErrorType(errorType)) {
throw new Error('Expected error type is not an Error.'); throw new Error(getErrorMsg('Expected error type is not an Error.'));
} }
} }
if (expected && !isStringOrRegExp(expected)) { if (expected && !isStringOrRegExp(expected)) {
if (errorType) { if (errorType) {
throw new Error('Expected error message is not a string or RegExp.'); throw new Error(getErrorMsg('Expected error message is not a string or RegExp.'));
} else { } else {
throw new Error('Expected is not an Error, string, or RegExp.'); throw new Error(getErrorMsg('Expected is not an Error, string, or RegExp.'));
} }
} }