export function assertMap<V>(map:Map<string, V>, values:any, assertion:AssertCB<V>, message:string):void { assert.isObject(map, message + ': map'); assert.isObject(values, message + ': values'); assert.isFunction(assertion, message + ': assertion'); var mapKeys:string[] = xm.keysOf(map).sort(); var valueKeys:string[] = Object.keys(values).sort(); assert.sameMembers(mapKeys, valueKeys, message + ': same paths'); var keys:string[] = mapKeys.slice(0); valueKeys.forEach((key:string) => { var i = keys.indexOf(key); assert(i > -1, message + ': expected key "' + key + '"'); keys.splice(i, 1); assert(map.has(key), message + ': missing key "' + key + '"'); assertion(map.get(key), values[key], message + ': key "' + key + '"'); }); assert(keys.length === 0, message + ': unexpected keys remaining: ' + keys + ''); }
export function assertUnorderedNaive<T>(actual:T[], expected:T[], assertion:AssertCB<T>, message:string):void { assert.isArray(actual, 'actual'); assert.isArray(expected, 'expected'); assert.isFunction(assertion, 'assertion'); assert.strictEqual(actual.length, expected.length, message + ': length not equal: ' + actual.length + ' != ' + expected.length); // clones var actualQueue = actual.slice(0); var expectedQueue = expected.slice(0); outer : while (actualQueue.length > 0) { var act = actualQueue.pop(); for (var i = 0, ii = expectedQueue.length; i < ii; i++) { var exp = expectedQueue[i]; // try every assertion try { assertion(act, exp, message); // passed, remove it expectedQueue.splice(i, 1); // jump continue outer; } catch (err) { // maybe next one } } assert(false, message + ': no matching element for actual: ' + xm.toValueStrim(act)); } // also bad if (expectedQueue.length > 0) { // use assert.deepEqual for diff report assert.deepEqual([], expectedQueue, message + ': remaining expect elements: ' + expectedQueue.length); } }
it('is defined', () => { assert.isFunction(tsd.Def, 'Def'); });
it('is constructor', () => { assert.isFunction(xm.JSONStabilizer); });
it('should be defined', () => { assert.isFunction(git.GithubURLs, 'GithubURLs.constructor'); });
it('is constructor', () => { assert.isFunction(xm.JSONPointer); });
it('should exist', () => { assert.isFunction(xm.http.HTTPCache, 'cache'); assert.isFunction(xm.http.CacheOpts, 'opts'); assert.isFunction(xm.http.CacheObject, 'object'); assert.isFunction(xm.http.CacheRequest, 'request'); });
it('should be defined', () => { assert.isFunction(xm.URLManager, 'constructor'); });
it('returns a function if only one argument provided', function () { assert.isFunction(isStrictEqual(1)); });
it('should be defined', () => { assert.isFunction(tsd.Core, 'constructor'); });