mock-angular.js
function isMatch(config, mock) {
		if (angular.isFunction(mock)) {
			return !!mock(config.method, config.url, config.params, config.data, config.headers);
		}
		mock = mock || {};
		var fail = false;
		if (mock.method) {
			fail = fail || (config.method ? config.method.toLowerCase() : 'get') != mock.method.toLowerCase();
		}
		if (mock.url && angular.isString(config.url) && angular.isString(mock.url)) {
			fail = fail || config.url.split('?')[0] != mock.url.split('?')[0];
		}
		if (mock.params || angular.isString(config.url) && config.url.split('?')[1]) {
			var configParams = angular.extend(queryParams(config.url.split('?')[1]), config.params);
			var mockParams = angular.isString(mock.url) ? queryParams(mock.url.split('?')[1]) : {};
			mockParams = angular.extend(mockParams, mock.params);
			fail = fail || !angular.equals(configParams, mockParams);
		}
		if (mock.data) {
			fail = fail || !angular.equals(config.data, mock.data);
		}
		// Header props can be functions
		if (mock.headers) {
			var headers = {};
			angular.forEach(config.headers, function(value, key) {
				if (angular.isFunction(value)) {
					value = value(config);
				}
				if (value) {
					headers[key] = value;
				}
			});
			fail = fail || !angular.equals(headers, mock.headers);
		}
		return !fail;
	}
function isMatch(config, mock) {
		if (angular.isFunction(mock)) {
			return !!mock(config.method, config.url, config.params, config.data, config.headers);
		}
		mock = mock || {};
		var fail = false;
		if (mock.method) {
			fail = fail || (config.method ? config.method.toLowerCase() : 'get') != mock.method.toLowerCase();
		}
		if (mock.url && angular.isString(config.url) && angular.isString(mock.url)) {
			fail = fail || config.url.split('?')[0] != mock.url.split('?')[0];
		}
		if (mock.params || angular.isString(config.url) && config.url.split('?')[1]) {
			var configParams = angular.extend(queryParams(config.url.split('?')[1]), config.params);
			var mockParams = angular.isString(mock.url) ? queryParams(mock.url.split('?')[1]) : {};
			mockParams = angular.extend(mockParams, mock.params);
			fail = fail || !angular.equals(configParams, mockParams);
		}
		if (mock.data) {
			fail = fail || !angular.equals(config.data, mock.data);
		}
		// Header props can be functions
		if (mock.headers) {
			var headers = {};
			angular.forEach(config.headers, function(value, key) {
				if (angular.isFunction(value)) {
					value = value(config);
				}
				if (value) {
					headers[key] = value;
				}
			});
			fail = fail || !angular.equals(headers, mock.headers);
		}
		return !fail;
	}
function isMatch ( config , mock ) { if ( angular . isFunction ( mock ) ) { return ! ! mock ( config . method , config . url , config . params , config . data , config . headers ) ; } mock = mock || { } ; var fail = false ; if ( mock . method ) { fail = fail || ( config . method ? config . method . toLowerCase ( ) : 'get' ) != mock . method . toLowerCase ( ) ; } if ( mock . url && angular . isString ( config . url ) && angular . isString ( mock . url ) ) { fail = fail || config . url . split ( '?' ) [ 0 ] != mock . url . split ( '?' ) [ 0 ] ; } if ( mock . params || angular . isString ( config . url ) && config . url . split ( '?' ) [ 1 ] ) { var configParams = angular . extend ( queryParams ( config . url . split ( '?' ) [ 1 ] ) , config . params ) ; var mockParams = angular . isString ( mock . url ) ? queryParams ( mock . url . split ( '?' ) [ 1 ] ) : { } ; mockParams = angular . extend ( mockParams , mock . params ) ; fail = fail || ! angular . equals ( configParams , mockParams ) ; } if ( mock . data ) { fail = fail || ! angular . equals ( config . data , mock . data ) ; } // Header props can be functions if ( mock . headers ) { var headers = { } ; angular . forEach ( config . headers , function ( value , key ) { if ( angular . isFunction ( value ) ) { value = value ( config ) ; } if ( value ) { headers [ key ] = value ; } } ) ; fail = fail || ! angular . equals ( headers , mock . headers ) ; } return ! fail ; }
Any missing property on mock matches everything
@param config
@param mock
@returns bool
Any missing property on mock matches everything