Removed matchers

This commit is contained in:
Sean Lilley 2019-02-05 20:59:00 -05:00
parent b458856904
commit 50f4192afd
6 changed files with 0 additions and 398 deletions

View File

@ -1,216 +0,0 @@
//This file is a copy of https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Specs/addDefaultMatchers.js
/*eslint strict: ["error", "function"]*/
/*eslint-env amd*/
/*eslint-disable no-unused-vars*/
define([
'./equals',
'Cesium/Core/defined',
'Cesium/Core/DeveloperError',
'Cesium/Core/RuntimeError'
], function(
equals,
defined,
DeveloperError,
RuntimeError) {
'use strict';
function createMissingFunctionMessageFunction(item, actualPrototype, expectedInterfacePrototype) {
return function() {
return 'Expected function \'' + item + '\' to exist on ' + actualPrototype.constructor.name + ' because it should implement interface ' + expectedInterfacePrototype.constructor.name + '.';
};
}
function makeThrowFunction(debug, Type, name) {
if (debug) {
return function(util, customEqualityTesters) {
return {
compare : function(actual, expected) {
// based on the built-in Jasmine toThrow matcher
var result = false;
var exception;
if (typeof actual !== 'function') {
throw new Error('Actual is not a function');
}
try {
actual();
} catch (e) {
exception = e;
}
if (exception) {
result = exception instanceof Type;
}
var message;
if (result) {
message = ['Expected function not to throw ' + name + ' , but it threw', exception.message || exception].join(' ');
if (defined(expected)) {
expect(expected).toEqual(exception.message);
}
} else {
message = 'Expected function to throw ' + name + '.';
}
return {
pass : result,
message : message
};
}
};
};
}
return function() {
return {
compare : function(actual, expected) {
return { pass : true };
},
negativeCompare : function(actual, expected) {
return { pass : true };
}
};
};
}
function createDefaultMatchers(debug) {
return {
toBeGreaterThanOrEqualTo : function(util, customEqualityTesters) {
return {
compare: function(actual, expected) {
return { pass : actual >= expected };
}
};
},
toBeLessThanOrEqualTo : function(util, customEqualityTesters) {
return {
compare: function(actual, expected) {
return { pass : actual <= expected };
}
};
},
toBeBetween : function(util, customEqualityTesters) {
return {
compare: function(actual, lower, upper) {
if (lower > upper) {
var tmp = upper;
upper = lower;
lower = tmp;
}
return { pass : actual >= lower && actual <= upper };
}
};
},
toStartWith : function(util, customEqualityTesters) {
return {
compare: function(actual, expected) {
return { pass : actual.slice(0, expected.length) === expected };
}
};
},
toEndWith : function(util, customEqualityTesters) {
return {
compare: function(actual, expected) {
return { pass : actual.slice(-expected.length) === expected };
}
};
},
toEqual : function(util, customEqualityTesters) {
return {
compare: function(actual, expected) {
return { pass : equals(util, customEqualityTesters, actual, expected) };
}
};
},
toEqualEpsilon : function(util, customEqualityTesters) {
return {
compare: function(actual, expected, epsilon) {
function equalityTester(a, b) {
var to_run;
if (defined(a)) {
if (typeof a.equalsEpsilon === 'function') {
return a.equalsEpsilon(b, epsilon);
} else if (a instanceof Object) {
// Check if the current object has a static function named 'equalsEpsilon'
to_run = Object.getPrototypeOf(a).constructor.equalsEpsilon;
if (typeof to_run === 'function') {
return to_run(a, b, epsilon);
}
}
}
if (defined(b)) {
if (typeof b.equalsEpsilon === 'function') {
return b.equalsEpsilon(a, epsilon);
} else if (b instanceof Object) {
// Check if the current object has a static function named 'equalsEpsilon'
to_run = Object.getPrototypeOf(b).constructor.equalsEpsilon;
if (typeof to_run === 'function') {
return to_run(b, a, epsilon);
}
}
}
if (typeof a === 'number' || typeof b === 'number') {
return Math.abs(a - b) <= epsilon;
}
return undefined;
}
var result = equals(util, [equalityTester], actual, expected);
return { pass : result };
}
};
},
toConformToInterface : function(util, customEqualityTesters) {
return {
compare : function(actual, expectedInterface) {
// All function properties on the prototype should also exist on the actual's prototype.
var actualPrototype = actual.prototype;
var expectedInterfacePrototype = expectedInterface.prototype;
for ( var item in expectedInterfacePrototype) {
if (expectedInterfacePrototype.hasOwnProperty(item) && typeof expectedInterfacePrototype[item] === 'function' && !actualPrototype.hasOwnProperty(item)) {
return { pass : false, message : createMissingFunctionMessageFunction(item, actualPrototype, expectedInterfacePrototype) };
}
}
return { pass : true };
}
};
},
toBeInstanceOf : function(util, customEqualityTesters) {
return {
compare : function(actual, expectedConstructor) {
return { pass : actual instanceof expectedConstructor };
}
};
},
toThrow : function(expectedConstructor) {
throw new Error('Do not use toThrow. Use toThrowDeveloperError or toThrowRuntimeError instead.');
},
toThrowDeveloperError : makeThrowFunction(debug, DeveloperError, 'DeveloperError'),
toThrowRuntimeError : makeThrowFunction(true, RuntimeError, 'RuntimeError')
};
}
return function(debug) {
return function() {
this.addMatchers(createDefaultMatchers(debug));
};
};
});

View File

@ -1,16 +0,0 @@
/*eslint strict: ["error", "function"]*/
/*eslint-env amd*/
define([
'./addDefaultMatchers',
'./equalsMethodEqualityTester'
], function (addDefaultMatchers,
equalsMethodEqualityTester) {
'use strict';
return function (env) {
env.beforeEach(function () {
addDefaultMatchers(true).call(env);
env.addCustomEqualityTester(equalsMethodEqualityTester);
});
};
});

View File

@ -1,46 +0,0 @@
//This file is a copy of https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Specs/equals.js
/*eslint strict: ["error", "function"]*/
/*eslint-env amd*/
define([
'Cesium/Core/FeatureDetection'
], function(
FeatureDetection) {
'use strict';
/*global CanvasPixelArray*/
var typedArrayTypes = [];
// Earlier versions of IE do not support typed arrays
if (FeatureDetection.supportsTypedArrays()) {
typedArrayTypes.push(Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array);
if (typeof Uint8ClampedArray !== 'undefined') {
typedArrayTypes.push(Uint8ClampedArray);
}
if (typeof CanvasPixelArray !== 'undefined') {
typedArrayTypes.push(CanvasPixelArray);
}
}
function isTypedArray(o) {
return typedArrayTypes.some(function(type) {
return o instanceof type;
});
}
function typedArrayToArray(array) {
if (array !== null && typeof array === 'object' && isTypedArray(array)) {
return Array.prototype.slice.call(array, 0);
}
return array;
}
function equals(util, customEqualiyTesters, a, b) {
a = typedArrayToArray(a);
b = typedArrayToArray(b);
return util.equals(a, b, customEqualiyTesters);
}
return equals;
});

View File

@ -1,40 +0,0 @@
//This file is a copy of https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Specs/equalsMethodEqualityTester.js
/*eslint strict: ["error", "function"]*/
/*eslint-env amd*/
define([
'Cesium/Core/defined'
], function(
defined) {
'use strict';
return function(a, b) {
var to_run;
// if either a or b have an equals method, call it.
if (a !== null && defined(a)) {
if (typeof a.equals === 'function') {
return a.equals(b);
} else if(a instanceof Object) {
// Check if the current object has a static function named 'equals'
to_run = Object.getPrototypeOf(a).constructor.equals;
if( typeof to_run === 'function') {
return to_run(a, b);
}
}
}
if (b !== null && defined(b)) {
if (typeof b.equals === 'function') {
return b.equals(a);
} else if(b instanceof Object) {
// Check if the current object has a static function named 'equals'
to_run = Object.getPrototypeOf(b).constructor.equals;
if( typeof to_run === 'function') {
return to_run(b, a);
}
}
}
// fall back to default equality checks.
return undefined;
};
});

View File

@ -1,47 +0,0 @@
'use strict';
var Cesium = require('cesium');
var defined = Cesium.defined;
var defaultValue = Cesium.defaultValue;
module.exports = function expectPrommise(promise, done) {
return {
toResolve: function toResolve() {
return promise
.then(done)
.catch(function(err){
done.fail('Expected promise to resolve' + err);
});
},
toResolveWith: function toResolveWith(expectedValue) {
return promise
.then(function (result) {
expect(result).toEqual(expectedValue);
done();
})
.catch(function(err){
done.fail('Expected promise to resolve' + err);
});
},
toRejectWith: function toRejectWith(ErrorType, errorMessage) {
var typeName = defaultValue(ErrorType.displayName, ErrorType.name);
promise
.then(function () {
done.fail('expected promise to reject with ' + typeName);
})
.catch(function (error) {
if (!(error instanceof ErrorType)) {
done.fail(defaultValue(defaultValue(error.displayName, error.name), ErrorType) + ' to be instance of ' + typeName);
console.log(error);
}
if (defined(errorMessage)) {
expect(error.message).toEqual(errorMessage);
}
done();
});
}
};
};

View File

@ -1,33 +0,0 @@
'use strict';
var path = require('path');
var requirejs = require('requirejs');
var expectPromise = require('./expectPromise');
//Since Jasmine matchers are shared between client and server code
//We need to use requirejs to bring them into node.
requirejs.config({
baseUrl: path.join(__dirname, '../..'),
paths: {
'Cesium': 'node_modules/cesium/source'
},
nodeRequire: require
});
var customizeJasmine = requirejs('./specs/matchers/customizeJasmine');
var env = jasmine.getEnv();
customizeJasmine(env);
var oldExpect = global.expect;
global.expect = function (promise, done) {
//We can't use instanceof Promise here because promise
//may not be a bluebird-defined Promise
if (promise && promise.then && done) {
return expectPromise(promise, done);
}
//If it wasn't a promise, call original implementation
return oldExpect.apply(global, arguments);
};