From 4ad39a5c96dd99acf819ce189b13fec946d7506b Mon Sep 17 00:00:00 2001 From: talasila Date: Tue, 7 Feb 2017 15:03:57 -0500 Subject: Initial OpenECOMP Portal commit Change-Id: I804b80e0830c092e307da1599bd9fbb5c3e2da77 Signed-off-by: talasila --- .../bower_components/lodash/test/asset/test-ui.js | 170 + .../bower_components/lodash/test/asset/worker.js | 15 + .../bower_components/lodash/test/backbone.html | 170 + .../client/bower_components/lodash/test/fp.html | 41 + .../client/bower_components/lodash/test/index.html | 351 + .../client/bower_components/lodash/test/remove.js | 27 + .../bower_components/lodash/test/saucelabs.js | 914 + .../client/bower_components/lodash/test/test-fp.js | 2173 ++ .../client/bower_components/lodash/test/test.js | 26729 +++++++++++++++++++ .../bower_components/lodash/test/underscore.html | 484 + 10 files changed, 31074 insertions(+) create mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/asset/test-ui.js create mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/asset/worker.js create mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/backbone.html create mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/fp.html create mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/index.html create mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/remove.js create mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/saucelabs.js create mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/test-fp.js create mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/test.js create mode 100644 ecomp-portal-FE/client/bower_components/lodash/test/underscore.html (limited to 'ecomp-portal-FE/client/bower_components/lodash/test') diff --git a/ecomp-portal-FE/client/bower_components/lodash/test/asset/test-ui.js b/ecomp-portal-FE/client/bower_components/lodash/test/asset/test-ui.js new file mode 100644 index 00000000..24f087a4 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/lodash/test/asset/test-ui.js @@ -0,0 +1,170 @@ +;(function(window) { + 'use strict'; + + /** The base path of the lodash builds. */ + var basePath = '../'; + + /** The lodash build to load. */ + var build = (build = /build=([^&]+)/.exec(location.search)) && decodeURIComponent(build[1]); + + /** The module loader to use. */ + var loader = (loader = /loader=([^&]+)/.exec(location.search)) && decodeURIComponent(loader[1]); + + /** The `ui` object. */ + var ui = {}; + + /*--------------------------------------------------------------------------*/ + + /** + * Registers an event listener on an element. + * + * @private + * @param {Element} element The element. + * @param {string} eventName The name of the event. + * @param {Function} handler The event handler. + * @returns {Element} The element. + */ + function addListener(element, eventName, handler) { + if (typeof element.addEventListener != 'undefined') { + element.addEventListener(eventName, handler, false); + } else if (typeof element.attachEvent != 'undefined') { + element.attachEvent('on' + eventName, handler); + } + } + + /*--------------------------------------------------------------------------*/ + + // Initialize controls. + addListener(window, 'load', function() { + function eventHandler(event) { + var buildIndex = buildList.selectedIndex, + loaderIndex = loaderList.selectedIndex, + search = location.search.replace(/^\?|&?(?:build|loader)=[^&]*&?/g, ''); + + if (event.stopPropagation) { + event.stopPropagation(); + } else { + event.cancelBubble = true; + } + location.href = + location.href.split('?')[0] + '?' + + (search ? search + '&' : '') + + 'build=' + (buildIndex < 0 ? build : buildList[buildIndex].value) + '&' + + 'loader=' + (loaderIndex < 0 ? loader : loaderList[loaderIndex].value); + } + + function init() { + var toolbar = document.getElementById('qunit-testrunner-toolbar'); + if (!toolbar) { + setTimeout(init, 15); + return; + } + toolbar.appendChild(span1); + toolbar.appendChild(span2); + + buildList.selectedIndex = (function() { + switch (build) { + case 'lodash': return 1; + case 'lodash-core-dev': return 2; + case 'lodash-core': return 3; + case 'lodash-dev': + case null: return 0; + } + return -1; + }()); + + loaderList.selectedIndex = (function() { + switch (loader) { + case 'curl': return 1; + case 'dojo': return 2; + case 'requirejs': return 3; + case 'none': + case null: return 0; + } + return -1; + }()); + + addListener(buildList, 'change', eventHandler); + addListener(loaderList, 'change', eventHandler); + } + + var span1 = document.createElement('span'); + span1.style.cssText = 'float:right'; + span1.innerHTML = + '' + + ''; + + var span2 = document.createElement('span'); + span2.style.cssText = 'float:right'; + span2.innerHTML = + '' + + ''; + + var buildList = span1.lastChild, + loaderList = span2.lastChild; + + setTimeout(function() { + ui.timing.loadEventEnd = +new Date; + }, 1); + + init(); + }); + + // The lodash build file path. + ui.buildPath = (function() { + var result; + switch (build) { + case 'lodash': result = 'dist/lodash.min.js'; break; + case 'lodash-core-dev': result = 'dist/lodash.core.js'; break; + case 'lodash-core': result = 'dist/lodash.core.min.js'; break; + case null: build = 'lodash-dev'; + case 'lodash-dev': result = 'lodash.js'; break; + default: return build; + } + return basePath + result; + }()); + + // The module loader file path. + ui.loaderPath = (function() { + var result; + switch (loader) { + case 'curl': result = 'node_modules/curl-amd/dist/curl-kitchen-sink/curl.js'; break; + case 'dojo': result = 'node_modules/dojo/dojo.js'; break; + case 'requirejs': result = 'node_modules/requirejs/require.js'; break; + case null: loader = 'none'; return ''; + default: return loader; + } + return basePath + result; + }()); + + // Used to indicate testing a core build. + ui.isCore = /\bcore(\.min)?\.js\b/.test(ui.buildPath); + + // Used to indicate testing a foreign file. + ui.isForeign = RegExp('^(\\w+:)?//').test(build); + + // Used to indicate testing a modularized build. + ui.isModularize = /\b(?:amd|commonjs|es|node|npm|(index|main)\.js)\b/.test([location.pathname, location.search]); + + // Used to indicate testing in Sauce Labs' automated test cloud. + ui.isSauceLabs = location.port == '9001'; + + // Used to indicate that lodash is in strict mode. + ui.isStrict = /\bes\b/.test([location.pathname, location.search]); + + ui.urlParams = { 'build': build, 'loader': loader }; + ui.timing = { 'loadEventEnd': 0 }; + + window.ui = ui; + +}(this)); diff --git a/ecomp-portal-FE/client/bower_components/lodash/test/asset/worker.js b/ecomp-portal-FE/client/bower_components/lodash/test/asset/worker.js new file mode 100644 index 00000000..8ccffa87 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/lodash/test/asset/worker.js @@ -0,0 +1,15 @@ +self.console || (self.console = { 'log': function() {} }); + +addEventListener('message', function(e) { + if (e.data) { + try { + importScripts('../' + e.data); + } catch (e) { + var lineNumber = e.lineNumber, + message = (lineNumber == null ? '' : (lineNumber + ': ')) + e.message; + + self._ = { 'VERSION': message }; + } + postMessage(_.VERSION); + } +}, false); diff --git a/ecomp-portal-FE/client/bower_components/lodash/test/backbone.html b/ecomp-portal-FE/client/bower_components/lodash/test/backbone.html new file mode 100644 index 00000000..dd3df9fe --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/lodash/test/backbone.html @@ -0,0 +1,170 @@ + + + + + Backbone Test Suite + + + + + + + + + + + + + + + diff --git a/ecomp-portal-FE/client/bower_components/lodash/test/fp.html b/ecomp-portal-FE/client/bower_components/lodash/test/fp.html new file mode 100644 index 00000000..71229666 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/lodash/test/fp.html @@ -0,0 +1,41 @@ + + + + + lodash-fp Test Suite + + + + + + + + + + + +
+ + + diff --git a/ecomp-portal-FE/client/bower_components/lodash/test/index.html b/ecomp-portal-FE/client/bower_components/lodash/test/index.html new file mode 100644 index 00000000..aee39424 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/lodash/test/index.html @@ -0,0 +1,351 @@ + + + + + lodash Test Suite + + + + + + + + + + + +
+
+
+ + + + + diff --git a/ecomp-portal-FE/client/bower_components/lodash/test/remove.js b/ecomp-portal-FE/client/bower_components/lodash/test/remove.js new file mode 100644 index 00000000..bd5aaf92 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/lodash/test/remove.js @@ -0,0 +1,27 @@ +#!/usr/bin/env node +'use strict'; + +var _ = require('../lodash'), + fs = require('fs'), + path = require('path'); + +var args = (args = process.argv) + .slice((args[0] === process.execPath || args[0] === 'node') ? 2 : 0); + +var filePath = path.resolve(args[1]), + reLine = /.*/gm; + +var pattern = (function() { + var result = args[0], + delimiter = result.charAt(0), + lastIndex = result.lastIndexOf(delimiter); + + return RegExp(result.slice(1, lastIndex), result.slice(lastIndex + 1)); +}()); + +/*----------------------------------------------------------------------------*/ + +fs.writeFileSync(filePath, fs.readFileSync(filePath, 'utf8').replace(pattern, function(match) { + var snippet = _.slice(arguments, -3, -2)[0]; + return match.replace(snippet, snippet.replace(reLine, '')); +})); diff --git a/ecomp-portal-FE/client/bower_components/lodash/test/saucelabs.js b/ecomp-portal-FE/client/bower_components/lodash/test/saucelabs.js new file mode 100644 index 00000000..f8a7554f --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/lodash/test/saucelabs.js @@ -0,0 +1,914 @@ +#!/usr/bin/env node +'use strict'; + +/** Environment shortcut. */ +var env = process.env; + +if (env.TRAVIS_SECURE_ENV_VARS == 'false') { + console.log('Skipping Sauce Labs jobs; secure environment variables are unavailable'); + process.exit(0); +} + +/** Load Node.js modules. */ +var EventEmitter = require('events').EventEmitter, + http = require('http'), + path = require('path'), + url = require('url'), + util = require('util'); + +/** Load other modules. */ +var _ = require('../lodash.js'), + chalk = require('chalk'), + ecstatic = require('ecstatic'), + request = require('request'), + SauceTunnel = require('sauce-tunnel'); + +/** Used for Sauce Labs credentials. */ +var accessKey = env.SAUCE_ACCESS_KEY, + username = env.SAUCE_USERNAME; + +/** Used as the default maximum number of times to retry a job and tunnel. */ +var maxJobRetries = 3, + maxTunnelRetries = 3; + +/** Used as the static file server middleware. */ +var mount = ecstatic({ + 'cache': 'no-cache', + 'root': process.cwd() +}); + +/** Used as the list of ports supported by Sauce Connect. */ +var ports = [ + 80, 443, 888, 2000, 2001, 2020, 2109, 2222, 2310, 3000, 3001, 3030, 3210, + 3333, 4000, 4001, 4040, 4321, 4502, 4503, 4567, 5000, 5001, 5050, 5555, 5432, + 6000, 6001, 6060, 6666, 6543, 7000, 7070, 7774, 7777, 8000, 8001, 8003, 8031, + 8080, 8081, 8765, 8777, 8888, 9000, 9001, 9080, 9090, 9876, 9877, 9999, 49221, + 55001 +]; + +/** Used by `logInline` to clear previously logged messages. */ +var prevLine = ''; + +/** Method shortcut. */ +var push = Array.prototype.push; + +/** Used to detect error messages. */ +var reError = /(?:\be|E)rror\b/; + +/** Used to detect valid job ids. */ +var reJobId = /^[a-z0-9]{32}$/; + +/** Used to display the wait throbber. */ +var throbberDelay = 500, + waitCount = -1; + +/** + * Used as Sauce Labs config values. + * See the [Sauce Labs documentation](https://docs.saucelabs.com/reference/test-configuration/) + * for more details. + */ +var advisor = getOption('advisor', false), + build = getOption('build', (env.TRAVIS_COMMIT || '').slice(0, 10)), + commandTimeout = getOption('commandTimeout', 90), + compatMode = getOption('compatMode', null), + customData = Function('return {' + getOption('customData', '').replace(/^\{|}$/g, '') + '}')(), + deviceOrientation = getOption('deviceOrientation', 'portrait'), + framework = getOption('framework', 'qunit'), + idleTimeout = getOption('idleTimeout', 60), + jobName = getOption('name', 'unit tests'), + maxDuration = getOption('maxDuration', 180), + port = ports[Math.min(_.sortedIndex(ports, getOption('port', 9001)), ports.length - 1)], + publicAccess = getOption('public', true), + queueTimeout = getOption('queueTimeout', 240), + recordVideo = getOption('recordVideo', true), + recordScreenshots = getOption('recordScreenshots', false), + runner = getOption('runner', 'test/index.html').replace(/^\W+/, ''), + runnerUrl = getOption('runnerUrl', 'http://localhost:' + port + '/' + runner), + statusInterval = getOption('statusInterval', 5), + tags = getOption('tags', []), + throttled = getOption('throttled', 10), + tunneled = getOption('tunneled', true), + tunnelId = getOption('tunnelId', 'tunnel_' + (env.TRAVIS_JOB_ID || 0)), + tunnelTimeout = getOption('tunnelTimeout', 120), + videoUploadOnPass = getOption('videoUploadOnPass', false); + +/** Used to convert Sauce Labs browser identifiers to their formal names. */ +var browserNameMap = { + 'googlechrome': 'Chrome', + 'iehta': 'Internet Explorer', + 'ipad': 'iPad', + 'iphone': 'iPhone', + 'microsoftedge': 'Edge' +}; + +/** List of platforms to load the runner on. */ +var platforms = [ + ['Linux', 'android', '5.1'], + ['Windows 10', 'chrome', '50'], + ['Windows 10', 'chrome', '49'], + ['Windows 10', 'firefox', '46'], + ['Windows 10', 'firefox', '45'], + ['Windows 10', 'microsoftedge', '13'], + ['Windows 10', 'internet explorer', '11'], + ['Windows 8', 'internet explorer', '10'], + ['Windows 7', 'internet explorer', '9'], + // ['OS X 10.10', 'ipad', '9.1'], + ['OS X 10.11', 'safari', '9'], + ['OS X 10.10', 'safari', '8'] +]; + +/** Used to tailor the `platforms` array. */ +var isAMD = _.includes(tags, 'amd'), + isBackbone = _.includes(tags, 'backbone'), + isModern = _.includes(tags, 'modern'); + +// The platforms to test IE compatibility modes. +if (compatMode) { + platforms = [ + ['Windows 10', 'internet explorer', '11'], + ['Windows 8', 'internet explorer', '10'], + ['Windows 7', 'internet explorer', '9'], + ['Windows 7', 'internet explorer', '8'] + ]; +} +// The platforms for AMD tests. +if (isAMD) { + platforms = _.filter(platforms, function(platform) { + var browser = browserName(platform[1]), + version = +platform[2]; + + switch (browser) { + case 'Android': return version >= 4.4; + case 'Opera': return version >= 10; + } + return true; + }); +} +// The platforms for Backbone tests. +if (isBackbone) { + platforms = _.filter(platforms, function(platform) { + var browser = browserName(platform[1]), + version = +platform[2]; + + switch (browser) { + case 'Firefox': return version >= 4; + case 'Internet Explorer': return version >= 7; + case 'iPad': return version >= 5; + case 'Opera': return version >= 12; + } + return true; + }); +} +// The platforms for modern builds. +if (isModern) { + platforms = _.filter(platforms, function(platform) { + var browser = browserName(platform[1]), + version = +platform[2]; + + switch (browser) { + case 'Android': return version >= 4.1; + case 'Firefox': return version >= 10; + case 'Internet Explorer': return version >= 9; + case 'iPad': return version >= 6; + case 'Opera': return version >= 12; + case 'Safari': return version >= 6; + } + return true; + }); +} + +/** Used as the default `Job` options object. */ +var jobOptions = { + 'build': build, + 'command-timeout': commandTimeout, + 'custom-data': customData, + 'device-orientation': deviceOrientation, + 'framework': framework, + 'idle-timeout': idleTimeout, + 'max-duration': maxDuration, + 'name': jobName, + 'public': publicAccess, + 'platforms': platforms, + 'record-screenshots': recordScreenshots, + 'record-video': recordVideo, + 'sauce-advisor': advisor, + 'tags': tags, + 'url': runnerUrl, + 'video-upload-on-pass': videoUploadOnPass +}; + +if (publicAccess === true) { + jobOptions['public'] = 'public'; +} +if (tunneled) { + jobOptions['tunnel-identifier'] = tunnelId; +} + +/*----------------------------------------------------------------------------*/ + +/** + * Resolves the formal browser name for a given Sauce Labs browser identifier. + * + * @private + * @param {string} identifier The browser identifier. + * @returns {string} Returns the formal browser name. + */ +function browserName(identifier) { + return browserNameMap[identifier] || _.startCase(identifier); +} + +/** + * Gets the value for the given option name. If no value is available the + * `defaultValue` is returned. + * + * @private + * @param {string} name The name of the option. + * @param {*} defaultValue The default option value. + * @returns {*} Returns the option value. + */ +function getOption(name, defaultValue) { + var isArr = _.isArray(defaultValue); + return _.reduce(process.argv, function(result, value) { + if (isArr) { + value = optionToArray(name, value); + return _.isEmpty(value) ? result : value; + } + value = optionToValue(name, value); + + return value == null ? result : value; + }, defaultValue); +} + +/** + * Checks if `value` is a job ID. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a job ID, else `false`. + */ +function isJobId(value) { + return reJobId.test(value); +} + +/** + * Writes an inline message to standard output. + * + * @private + * @param {string} [text=''] The text to log. + */ +function logInline(text) { + var blankLine = _.repeat(' ', _.size(prevLine)); + prevLine = text = _.truncate(text, { 'length': 40 }); + process.stdout.write(text + blankLine.slice(text.length) + '\r'); +} + +/** + * Writes the wait throbber to standard output. + * + * @private + */ +function logThrobber() { + logInline('Please wait' + _.repeat('.', (++waitCount % 3) + 1)); +} + +/** + * Converts a comma separated option value into an array. + * + * @private + * @param {string} name The name of the option to inspect. + * @param {string} string The options string. + * @returns {Array} Returns the new converted array. + */ +function optionToArray(name, string) { + return _.compact(_.invokeMap((optionToValue(name, string) || '').split(/, */), 'trim')); +} + +/** + * Extracts the option value from an option string. + * + * @private + * @param {string} name The name of the option to inspect. + * @param {string} string The options string. + * @returns {string|undefined} Returns the option value, else `undefined`. + */ +function optionToValue(name, string) { + var result = string.match(RegExp('^' + name + '(?:=([\\s\\S]+))?$')); + if (result) { + result = _.result(result, 1); + result = result ? _.trim(result) : true; + } + if (result === 'false') { + return false; + } + return result || undefined; +} + +/*----------------------------------------------------------------------------*/ + +/** + * The `Job#remove` and `Tunnel#stop` callback used by `Jobs#restart` + * and `Tunnel#restart` respectively. + * + * @private + */ +function onGenericRestart() { + this.restarting = false; + this.emit('restart'); + this.start(); +} + +/** + * The `request.put` and `SauceTunnel#stop` callback used by `Jobs#stop` + * and `Tunnel#stop` respectively. + * + * @private + * @param {Object} [error] The error object. + */ +function onGenericStop(error) { + this.running = this.stopping = false; + this.emit('stop', error); +} + +/** + * The `request.del` callback used by `Jobs#remove`. + * + * @private + */ +function onJobRemove(error, res, body) { + this.id = this.taskId = this.url = null; + this.removing = false; + this.emit('remove'); +} + +/** + * The `Job#remove` callback used by `Jobs#reset`. + * + * @private + */ +function onJobReset() { + this.attempts = 0; + this.failed = this.resetting = false; + this._pollerId = this.id = this.result = this.taskId = this.url = null; + this.emit('reset'); +} + +/** + * The `request.post` callback used by `Jobs#start`. + * + * @private + * @param {Object} [error] The error object. + * @param {Object} res The response data object. + * @param {Object} body The response body JSON object. + */ +function onJobStart(error, res, body) { + this.starting = false; + + if (this.stopping) { + return; + } + var statusCode = _.result(res, 'statusCode'), + taskId = _.first(_.result(body, 'js tests')); + + if (error || !taskId || statusCode != 200) { + if (this.attempts < this.retries) { + this.restart(); + return; + } + var na = 'unavailable', + bodyStr = _.isObject(body) ? '\n' + JSON.stringify(body) : na, + statusStr = _.isFinite(statusCode) ? statusCode : na; + + logInline(); + console.error('Failed to start job; status: %s, body: %s', statusStr, bodyStr); + if (error) { + console.error(error); + } + this.failed = true; + this.emit('complete'); + return; + } + this.running = true; + this.taskId = taskId; + this.timestamp = _.now(); + this.emit('start'); + this.status(); +} + +/** + * The `request.post` callback used by `Job#status`. + * + * @private + * @param {Object} [error] The error object. + * @param {Object} res The response data object. + * @param {Object} body The response body JSON object. + */ +function onJobStatus(error, res, body) { + this.checking = false; + + if (!this.running || this.stopping) { + return; + } + var completed = _.result(body, 'completed', false), + data = _.first(_.result(body, 'js tests')), + elapsed = (_.now() - this.timestamp) / 1000, + jobId = _.result(data, 'job_id', null), + jobResult = _.result(data, 'result', null), + jobStatus = _.result(data, 'status', ''), + jobUrl = _.result(data, 'url', null), + expired = (elapsed >= queueTimeout && !_.includes(jobStatus, 'in progress')), + options = this.options, + platform = options.platforms[0]; + + if (_.isObject(jobResult)) { + var message = _.result(jobResult, 'message'); + } else { + if (typeof jobResult == 'string') { + message = jobResult; + } + jobResult = null; + } + if (isJobId(jobId)) { + this.id = jobId; + this.result = jobResult; + this.url = jobUrl; + } else { + completed = false; + } + this.emit('status', jobStatus); + + if (!completed && !expired) { + this._pollerId = _.delay(_.bind(this.status, this), this.statusInterval * 1000); + return; + } + var description = browserName(platform[1]) + ' ' + platform[2] + ' on ' + _.startCase(platform[0]), + errored = !jobResult || !jobResult.passed || reError.test(message) || reError.test(jobStatus), + failures = _.result(jobResult, 'failed'), + label = options.name + ':', + tunnel = this.tunnel; + + if (errored || failures) { + if (errored && this.attempts < this.retries) { + this.restart(); + return; + } + var details = 'See ' + jobUrl + ' for details.'; + this.failed = true; + + logInline(); + if (failures) { + console.error(label + ' %s ' + chalk.red('failed') + ' %d test' + (failures > 1 ? 's' : '') + '. %s', description, failures, details); + } + else if (tunnel.attempts < tunnel.retries) { + tunnel.restart(); + return; + } + else { + if (typeof message == 'undefined') { + message = 'Results are unavailable. ' + details; + } + console.error(label, description, chalk.red('failed') + ';', message); + } + } + else { + logInline(); + console.log(label, description, chalk.green('passed')); + } + this.running = false; + this.emit('complete'); +} + +/** + * The `SauceTunnel#start` callback used by `Tunnel#start`. + * + * @private + * @param {boolean} success The connection success indicator. + */ +function onTunnelStart(success) { + this.starting = false; + + if (this._timeoutId) { + clearTimeout(this._timeoutId); + this._timeoutId = null; + } + if (!success) { + if (this.attempts < this.retries) { + this.restart(); + return; + } + logInline(); + console.error('Failed to open Sauce Connect tunnel'); + process.exit(2); + } + logInline(); + console.log('Sauce Connect tunnel opened'); + + var jobs = this.jobs; + push.apply(jobs.queue, jobs.all); + + this.running = true; + this.emit('start'); + + console.log('Starting jobs...'); + this.dequeue(); +} + +/*----------------------------------------------------------------------------*/ + +/** + * The Job constructor. + * + * @private + * @param {Object} [properties] The properties to initialize a job with. + */ +function Job(properties) { + EventEmitter.call(this); + + this.options = {}; + _.merge(this, properties); + _.defaults(this.options, _.cloneDeep(jobOptions)); + + this.attempts = 0; + this.checking = this.failed = this.removing = this.resetting = this.restarting = this.running = this.starting = this.stopping = false; + this._pollerId = this.id = this.result = this.taskId = this.url = null; +} + +util.inherits(Job, EventEmitter); + +/** + * Removes the job. + * + * @memberOf Job + * @param {Function} callback The function called once the job is removed. + * @param {Object} Returns the job instance. + */ +Job.prototype.remove = function(callback) { + this.once('remove', _.iteratee(callback)); + if (this.removing) { + return this; + } + this.removing = true; + return this.stop(function() { + var onRemove = _.bind(onJobRemove, this); + if (!this.id) { + _.defer(onRemove); + return; + } + request.del(_.template('https://saucelabs.com/rest/v1/${user}/jobs/${id}')(this), { + 'auth': { 'user': this.user, 'pass': this.pass } + }, onRemove); + }); +}; + +/** + * Resets the job. + * + * @memberOf Job + * @param {Function} callback The function called once the job is reset. + * @param {Object} Returns the job instance. + */ +Job.prototype.reset = function(callback) { + this.once('reset', _.iteratee(callback)); + if (this.resetting) { + return this; + } + this.resetting = true; + return this.remove(onJobReset); +}; + +/** + * Restarts the job. + * + * @memberOf Job + * @param {Function} callback The function called once the job is restarted. + * @param {Object} Returns the job instance. + */ +Job.prototype.restart = function(callback) { + this.once('restart', _.iteratee(callback)); + if (this.restarting) { + return this; + } + this.restarting = true; + + var options = this.options, + platform = options.platforms[0], + description = browserName(platform[1]) + ' ' + platform[2] + ' on ' + _.startCase(platform[0]), + label = options.name + ':'; + + logInline(); + console.log('%s %s restart %d of %d', label, description, ++this.attempts, this.retries); + + return this.remove(onGenericRestart); +}; + +/** + * Starts the job. + * + * @memberOf Job + * @param {Function} callback The function called once the job is started. + * @param {Object} Returns the job instance. + */ +Job.prototype.start = function(callback) { + this.once('start', _.iteratee(callback)); + if (this.starting || this.running) { + return this; + } + this.starting = true; + request.post(_.template('https://saucelabs.com/rest/v1/${user}/js-tests')(this), { + 'auth': { 'user': this.user, 'pass': this.pass }, + 'json': this.options + }, _.bind(onJobStart, this)); + + return this; +}; + +/** + * Checks the status of a job. + * + * @memberOf Job + * @param {Function} callback The function called once the status is resolved. + * @param {Object} Returns the job instance. + */ +Job.prototype.status = function(callback) { + this.once('status', _.iteratee(callback)); + if (this.checking || this.removing || this.resetting || this.restarting || this.starting || this.stopping) { + return this; + } + this._pollerId = null; + this.checking = true; + request.post(_.template('https://saucelabs.com/rest/v1/${user}/js-tests/status')(this), { + 'auth': { 'user': this.user, 'pass': this.pass }, + 'json': { 'js tests': [this.taskId] } + }, _.bind(onJobStatus, this)); + + return this; +}; + +/** + * Stops the job. + * + * @memberOf Job + * @param {Function} callback The function called once the job is stopped. + * @param {Object} Returns the job instance. + */ +Job.prototype.stop = function(callback) { + this.once('stop', _.iteratee(callback)); + if (this.stopping) { + return this; + } + this.stopping = true; + if (this._pollerId) { + clearTimeout(this._pollerId); + this._pollerId = null; + this.checking = false; + } + var onStop = _.bind(onGenericStop, this); + if (!this.running || !this.id) { + _.defer(onStop); + return this; + } + request.put(_.template('https://saucelabs.com/rest/v1/${user}/jobs/${id}/stop')(this), { + 'auth': { 'user': this.user, 'pass': this.pass } + }, onStop); + + return this; +}; + +/*----------------------------------------------------------------------------*/ + +/** + * The Tunnel constructor. + * + * @private + * @param {Object} [properties] The properties to initialize the tunnel with. + */ +function Tunnel(properties) { + EventEmitter.call(this); + + _.merge(this, properties); + + var active = [], + queue = []; + + var all = _.map(this.platforms, _.bind(function(platform) { + return new Job(_.merge({ + 'user': this.user, + 'pass': this.pass, + 'tunnel': this, + 'options': { 'platforms': [platform] } + }, this.job)); + }, this)); + + var completed = 0, + restarted = [], + success = true, + total = all.length, + tunnel = this; + + _.invokeMap(all, 'on', 'complete', function() { + _.pull(active, this); + if (success) { + success = !this.failed; + } + if (++completed == total) { + tunnel.stop(_.partial(tunnel.emit, 'complete', success)); + return; + } + tunnel.dequeue(); + }); + + _.invokeMap(all, 'on', 'restart', function() { + if (!_.includes(restarted, this)) { + restarted.push(this); + } + // Restart tunnel if all active jobs have restarted. + var threshold = Math.min(all.length, _.isFinite(throttled) ? throttled : 3); + if (tunnel.attempts < tunnel.retries && + active.length >= threshold && _.isEmpty(_.difference(active, restarted))) { + tunnel.restart(); + } + }); + + this.on('restart', function() { + completed = 0; + success = true; + restarted.length = 0; + }); + + this._timeoutId = null; + this.attempts = 0; + this.restarting = this.running = this.starting = this.stopping = false; + this.jobs = { 'active': active, 'all': all, 'queue': queue }; + this.connection = new SauceTunnel(this.user, this.pass, this.id, this.tunneled, ['-P', '0']); +} + +util.inherits(Tunnel, EventEmitter); + +/** + * Restarts the tunnel. + * + * @memberOf Tunnel + * @param {Function} callback The function called once the tunnel is restarted. + */ +Tunnel.prototype.restart = function(callback) { + this.once('restart', _.iteratee(callback)); + if (this.restarting) { + return this; + } + this.restarting = true; + + logInline(); + console.log('Tunnel %s: restart %d of %d', this.id, ++this.attempts, this.retries); + + var jobs = this.jobs, + active = jobs.active, + all = jobs.all; + + var reset = _.after(all.length, _.bind(this.stop, this, onGenericRestart)), + stop = _.after(active.length, _.partial(_.invokeMap, all, 'reset', reset)); + + if (_.isEmpty(active)) { + _.defer(stop); + } + if (_.isEmpty(all)) { + _.defer(reset); + } + _.invokeMap(active, 'stop', function() { + _.pull(active, this); + stop(); + }); + + if (this._timeoutId) { + clearTimeout(this._timeoutId); + this._timeoutId = null; + } + return this; +}; + +/** + * Starts the tunnel. + * + * @memberOf Tunnel + * @param {Function} callback The function called once the tunnel is started. + * @param {Object} Returns the tunnel instance. + */ +Tunnel.prototype.start = function(callback) { + this.once('start', _.iteratee(callback)); + if (this.starting || this.running) { + return this; + } + this.starting = true; + + logInline(); + console.log('Opening Sauce Connect tunnel...'); + + var onStart = _.bind(onTunnelStart, this); + if (this.timeout) { + this._timeoutId = _.delay(onStart, this.timeout * 1000, false); + } + this.connection.start(onStart); + return this; +}; + +/** + * Removes jobs from the queue and starts them. + * + * @memberOf Tunnel + * @param {Object} Returns the tunnel instance. + */ +Tunnel.prototype.dequeue = function() { + var count = 0, + jobs = this.jobs, + active = jobs.active, + queue = jobs.queue, + throttled = this.throttled; + + while (queue.length && (active.length < throttled)) { + var job = queue.shift(); + active.push(job); + _.delay(_.bind(job.start, job), ++count * 1000); + } + return this; +}; + +/** + * Stops the tunnel. + * + * @memberOf Tunnel + * @param {Function} callback The function called once the tunnel is stopped. + * @param {Object} Returns the tunnel instance. + */ +Tunnel.prototype.stop = function(callback) { + this.once('stop', _.iteratee(callback)); + if (this.stopping) { + return this; + } + this.stopping = true; + + logInline(); + console.log('Shutting down Sauce Connect tunnel...'); + + var jobs = this.jobs, + active = jobs.active; + + var stop = _.after(active.length, _.bind(function() { + var onStop = _.bind(onGenericStop, this); + if (this.running) { + this.connection.stop(onStop); + } else { + onStop(); + } + }, this)); + + jobs.queue.length = 0; + if (_.isEmpty(active)) { + _.defer(stop); + } + _.invokeMap(active, 'stop', function() { + _.pull(active, this); + stop(); + }); + + if (this._timeoutId) { + clearTimeout(this._timeoutId); + this._timeoutId = null; + } + return this; +}; + +/*----------------------------------------------------------------------------*/ + +// Cleanup any inline logs when exited via `ctrl+c`. +process.on('SIGINT', function() { + logInline(); + process.exit(); +}); + +// Create a web server for the current working directory. +http.createServer(function(req, res) { + // See http://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx. + if (compatMode && path.extname(url.parse(req.url).pathname) == '.html') { + res.setHeader('X-UA-Compatible', 'IE=' + compatMode); + } + mount(req, res); +}).listen(port); + +// Setup Sauce Connect so we can use this server from Sauce Labs. +var tunnel = new Tunnel({ + 'user': username, + 'pass': accessKey, + 'id': tunnelId, + 'job': { 'retries': maxJobRetries, 'statusInterval': statusInterval }, + 'platforms': platforms, + 'retries': maxTunnelRetries, + 'throttled': throttled, + 'tunneled': tunneled, + 'timeout': tunnelTimeout +}); + +tunnel.on('complete', function(success) { + process.exit(success ? 0 : 1); +}); + +tunnel.start(); + +setInterval(logThrobber, throbberDelay); diff --git a/ecomp-portal-FE/client/bower_components/lodash/test/test-fp.js b/ecomp-portal-FE/client/bower_components/lodash/test/test-fp.js new file mode 100644 index 00000000..1fd66875 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/lodash/test/test-fp.js @@ -0,0 +1,2173 @@ +;(function() { + + /** Used as a safe reference for `undefined` in pre-ES5 environments. */ + var undefined; + + /** Used as the size to cover large array optimizations. */ + var LARGE_ARRAY_SIZE = 200; + + /** Used as a reference to the global object. */ + var root = (typeof global == 'object' && global) || this; + + /** Used for native method references. */ + var arrayProto = Array.prototype; + + /** Method and object shortcuts. */ + var phantom = root.phantom, + argv = root.process && process.argv, + document = !phantom && root.document, + slice = arrayProto.slice, + WeakMap = root.WeakMap; + + /** Math helpers. */ + var add = function(x, y) { return x + y; }, + isEven = function(n) { return n % 2 == 0; }, + square = function(n) { return n * n; }; + + // Leak to avoid sporadic `noglobals` fails on Edge in Sauce Labs. + root.msWDfn = undefined; + + /*--------------------------------------------------------------------------*/ + + /** Load QUnit and extras. */ + var QUnit = root.QUnit || require('qunit-extras'); + + /** Load stable Lodash. */ + var _ = root._ || require('../lodash.js'); + + var convert = (function() { + var baseConvert = root.fp || require('../fp/_baseConvert.js'); + if (!root.fp) { + return function(name, func, options) { + return baseConvert(_, name, func, options); + }; + } + return function(name, func, options) { + if (typeof name == 'function') { + options = func; + func = name; + name = undefined; + } + return name === undefined + ? baseConvert(func, options) + : baseConvert(_.runInContext(), options)[name]; + }; + }()); + + var allFalseOptions = { + 'cap': false, + 'curry': false, + 'fixed': false, + 'immutable': false, + 'rearg': false + }; + + var fp = root.fp + ? (fp = _.noConflict(), _ = root._, fp) + : convert(_.runInContext()); + + var mapping = root.mapping || require('../fp/_mapping.js'); + + /*--------------------------------------------------------------------------*/ + + /** + * Skips a given number of tests with a passing result. + * + * @private + * @param {Object} assert The QUnit assert object. + * @param {number} [count=1] The number of tests to skip. + */ + function skipAssert(assert, count) { + count || (count = 1); + while (count--) { + assert.ok(true, 'test skipped'); + } + } + + /*--------------------------------------------------------------------------*/ + + if (argv) { + console.log('Running lodash/fp tests.'); + } + + QUnit.module('convert module'); + + (function() { + QUnit.test('should work with `name` and `func`', function(assert) { + assert.expect(2); + + var array = [1, 2, 3, 4], + remove = convert('remove', _.remove), + actual = remove(isEven)(array); + + assert.deepEqual(array, [1, 2, 3, 4]); + assert.deepEqual(actual, [1, 3]); + }); + + QUnit.test('should work with `name`, `func`, and `options`', function(assert) { + assert.expect(3); + + var array = [1, 2, 3, 4], + remove = convert('remove', _.remove, allFalseOptions); + + var actual = remove(array, function(n, index) { + return isEven(index); + }); + + assert.deepEqual(array, [2, 4]); + assert.deepEqual(actual, [1, 3]); + assert.deepEqual(remove(), []); + }); + + QUnit.test('should work with an object', function(assert) { + assert.expect(2); + + if (!document) { + var array = [1, 2, 3, 4], + lodash = convert({ 'remove': _.remove }), + actual = lodash.remove(isEven)(array); + + assert.deepEqual(array, [1, 2, 3, 4]); + assert.deepEqual(actual, [1, 3]); + } + else { + skipAssert(assert, 2); + } + }); + + QUnit.test('should work with an object and `options`', function(assert) { + assert.expect(3); + + if (!document) { + var array = [1, 2, 3, 4], + lodash = convert({ 'remove': _.remove }, allFalseOptions); + + var actual = lodash.remove(array, function(n, index) { + return isEven(index); + }); + + assert.deepEqual(array, [2, 4]); + assert.deepEqual(actual, [1, 3]); + assert.deepEqual(lodash.remove(), []); + } + else { + skipAssert(assert, 3); + } + }); + + QUnit.test('should work with lodash and `options`', function(assert) { + assert.expect(3); + + var array = [1, 2, 3, 4], + lodash = convert(_.runInContext(), allFalseOptions); + + var actual = lodash.remove(array, function(n, index) { + return isEven(index); + }); + + assert.deepEqual(array, [2, 4]); + assert.deepEqual(actual, [1, 3]); + assert.deepEqual(lodash.remove(), []); + }); + + QUnit.test('should work with `runInContext` and `options`', function(assert) { + assert.expect(3); + + var array = [1, 2, 3, 4], + runInContext = convert('runInContext', _.runInContext, allFalseOptions), + lodash = runInContext(); + + var actual = lodash.remove(array, function(n, index) { + return isEven(index); + }); + + assert.deepEqual(array, [2, 4]); + assert.deepEqual(actual, [1, 3]); + assert.deepEqual(lodash.remove(), []); + }); + + QUnit.test('should accept a variety of options', function(assert) { + assert.expect(8); + + var array = [1, 2, 3, 4], + value = _.clone(array), + remove = convert('remove', _.remove, { 'cap': false }), + actual = remove(function(n, index) { return isEven(index); })(value); + + assert.deepEqual(value, [1, 2, 3, 4]); + assert.deepEqual(actual, [2, 4]); + + remove = convert('remove', _.remove, { 'curry': false }); + actual = remove(isEven); + + assert.deepEqual(actual, []); + + var trim = convert('trim', _.trim, { 'fixed': false }); + assert.strictEqual(trim('_-abc-_', '_-'), 'abc'); + + value = _.clone(array); + remove = convert('remove', _.remove, { 'immutable': false }); + actual = remove(isEven)(value); + + assert.deepEqual(value, [1, 3]); + assert.deepEqual(actual, [2, 4]); + + value = _.clone(array); + remove = convert('remove', _.remove, { 'rearg': false }); + actual = remove(value)(isEven); + + assert.deepEqual(value, [1, 2, 3, 4]); + assert.deepEqual(actual, [1, 3]); + }); + + QUnit.test('should respect the `cap` option', function(assert) { + assert.expect(1); + + var iteratee = convert('iteratee', _.iteratee, { 'cap': false }); + + var func = iteratee(function(a, b, c) { + return [a, b, c]; + }, 3); + + assert.deepEqual(func(1, 2, 3), [1, 2, 3]); + }); + + QUnit.test('should respect the `rearg` option', function(assert) { + assert.expect(1); + + var add = convert('add', _.add, { 'rearg': true }); + + assert.strictEqual(add('2')('1'), '12'); + }); + + QUnit.test('should only add a `placeholder` property if needed', function(assert) { + assert.expect(2); + + if (!document) { + var methodNames = _.keys(mapping.placeholder), + expected = _.map(methodNames, _.constant(true)); + + var actual = _.map(methodNames, function(methodName) { + var object = {}; + object[methodName] = _[methodName]; + + var lodash = convert(object); + return methodName in lodash; + }); + + assert.deepEqual(actual, expected); + + var lodash = convert({ 'add': _.add }); + assert.notOk('placeholder' in lodash); + } + else { + skipAssert(assert, 2); + } + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('method.convert'); + + (function() { + QUnit.test('should exist on unconverted methods', function(assert) { + assert.expect(2); + + var array = [], + isArray = fp.isArray.convert({ 'curry': true }); + + assert.strictEqual(fp.isArray(array), true); + assert.strictEqual(isArray()(array), true); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('convert methods'); + + _.each(['fp.convert', 'method.convert'], function(methodName) { + var isFp = methodName == 'fp.convert', + func = isFp ? fp.convert : fp.remove.convert; + + QUnit.test('`' + methodName + '` should work with an object', function(assert) { + assert.expect(3); + + var array = [1, 2, 3, 4], + lodash = func(allFalseOptions), + remove = isFp ? lodash.remove : lodash; + + var actual = remove(array, function(n, index) { + return isEven(index); + }); + + assert.deepEqual(array, [2, 4]); + assert.deepEqual(actual, [1, 3]); + assert.deepEqual(remove(), []); + }); + + QUnit.test('`' + methodName + '` should extend existing configs', function(assert) { + assert.expect(2); + + var array = [1, 2, 3, 4], + lodash = func({ 'cap': false }), + remove = (isFp ? lodash.remove : lodash).convert({ 'rearg': false }); + + var actual = remove(array)(function(n, index) { + return isEven(index); + }); + + assert.deepEqual(array, [1, 2, 3, 4]); + assert.deepEqual(actual, [2, 4]); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('method arity checks'); + + (function() { + QUnit.test('should wrap methods with an arity > `1`', function(assert) { + assert.expect(1); + + var methodNames = _.filter(_.functions(fp), function(methodName) { + return fp[methodName].length > 1; + }); + + assert.deepEqual(methodNames, []); + }); + + QUnit.test('should have >= arity of `aryMethod` designation', function(assert) { + assert.expect(4); + + _.times(4, function(index) { + var aryCap = index + 1; + + var methodNames = _.filter(mapping.aryMethod[aryCap], function(methodName) { + var key = _.result(mapping.remap, methodName, methodName), + arity = _[key].length; + + return arity != 0 && arity < aryCap; + }); + + assert.deepEqual(methodNames, [], '`aryMethod[' + aryCap + ']`'); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('method aliases'); + + (function() { + QUnit.test('should have correct aliases', function(assert) { + assert.expect(1); + + var actual = _.transform(mapping.aliasToReal, function(result, realName, alias) { + result.push([alias, fp[alias] === fp[realName]]); + }, []); + + assert.deepEqual(_.reject(actual, 1), []); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('method ary caps'); + + (function() { + QUnit.test('should have a cap of 1', function(assert) { + assert.expect(1); + + var funcMethods = [ + 'curry', 'iteratee', 'memoize', 'over', 'overEvery', 'overSome', + 'method', 'methodOf', 'rest', 'runInContext' + ]; + + var exceptions = funcMethods.concat('mixin', 'template'), + expected = _.map(mapping.aryMethod[1], _.constant(true)); + + var actual = _.map(mapping.aryMethod[1], function(methodName) { + var arg = _.includes(funcMethods, methodName) ? _.noop : 1, + result = _.attempt(function() { return fp[methodName](arg); }); + + if (_.includes(exceptions, methodName) + ? typeof result == 'function' + : typeof result != 'function' + ) { + return true; + } + console.log(methodName, result); + return false; + }); + + assert.deepEqual(actual, expected); + }); + + QUnit.test('should have a cap of 2', function(assert) { + assert.expect(1); + + var funcMethods = [ + 'after', 'ary', 'before', 'bind', 'bindKey', 'curryN', 'debounce', + 'delay', 'overArgs', 'partial', 'partialRight', 'rearg', 'throttle', + 'wrap' + ]; + + var exceptions = _.difference(funcMethods.concat('matchesProperty'), ['cloneDeepWith', 'cloneWith', 'delay']), + expected = _.map(mapping.aryMethod[2], _.constant(true)); + + var actual = _.map(mapping.aryMethod[2], function(methodName) { + var args = _.includes(funcMethods, methodName) ? [methodName == 'curryN' ? 1 : _.noop, _.noop] : [1, []], + result = _.attempt(function() { return fp[methodName](args[0])(args[1]); }); + + if (_.includes(exceptions, methodName) + ? typeof result == 'function' + : typeof result != 'function' + ) { + return true; + } + console.log(methodName, result); + return false; + }); + + assert.deepEqual(actual, expected); + }); + + QUnit.test('should have a cap of 3', function(assert) { + assert.expect(1); + + var funcMethods = [ + 'assignWith', 'extendWith', 'isEqualWith', 'isMatchWith', 'reduce', + 'reduceRight', 'transform', 'zipWith' + ]; + + var expected = _.map(mapping.aryMethod[3], _.constant(true)); + + var actual = _.map(mapping.aryMethod[3], function(methodName) { + var args = _.includes(funcMethods, methodName) ? [_.noop, 0, 1] : [0, 1, []], + result = _.attempt(function() { return fp[methodName](args[0])(args[1])(args[2]); }); + + if (typeof result != 'function') { + return true; + } + console.log(methodName, result); + return false; + }); + + assert.deepEqual(actual, expected); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('methods that use `indexOf`'); + + (function() { + QUnit.test('should work with `fp.indexOf`', function(assert) { + assert.expect(10); + + var array = ['a', 'b', 'c'], + other = ['b', 'd', 'b'], + object = { 'a': 1, 'b': 2, 'c': 2 }, + actual = fp.difference(array)(other); + + assert.deepEqual(actual, ['a', 'c'], 'fp.difference'); + + actual = fp.includes('b')(array); + assert.strictEqual(actual, true, 'fp.includes'); + + actual = fp.intersection(other)(array); + assert.deepEqual(actual, ['b'], 'fp.intersection'); + + actual = fp.omit(other)(object); + assert.deepEqual(actual, { 'a': 1, 'c': 2 }, 'fp.omit'); + + actual = fp.union(other)(array); + assert.deepEqual(actual, ['a', 'b', 'c', 'd'], 'fp.union'); + + actual = fp.uniq(other); + assert.deepEqual(actual, ['b', 'd'], 'fp.uniq'); + + actual = fp.uniqBy(_.identity, other); + assert.deepEqual(actual, ['b', 'd'], 'fp.uniqBy'); + + actual = fp.without(other)(array); + assert.deepEqual(actual, ['a', 'c'], 'fp.without'); + + actual = fp.xor(other)(array); + assert.deepEqual(actual, ['a', 'c', 'd'], 'fp.xor'); + + actual = fp.pull('b')(array); + assert.deepEqual(actual, ['a', 'c'], 'fp.pull'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('cherry-picked methods'); + + (function() { + QUnit.test('should provide the correct `iteratee` arguments', function(assert) { + assert.expect(4); + + var args, + array = [1, 2, 3], + object = { 'a': 1, 'b': 2 }, + isFIFO = _.keys(object)[0] == 'a', + map = convert('map', _.map), + reduce = convert('reduce', _.reduce); + + map(function() { + args || (args = slice.call(arguments)); + })(array); + + assert.deepEqual(args, [1]); + + args = undefined; + map(function() { + args || (args = slice.call(arguments)); + })(object); + + assert.deepEqual(args, isFIFO ? [1] : [2]); + + args = undefined; + reduce(function() { + args || (args = slice.call(arguments)); + })(0)(array); + + assert.deepEqual(args, [0, 1]); + + args = undefined; + reduce(function() { + args || (args = slice.call(arguments)); + })(0)(object); + + assert.deepEqual(args, isFIFO ? [0, 1] : [0, 2]); + }); + + QUnit.test('should not support shortcut fusion', function(assert) { + assert.expect(3); + + var array = fp.range(0, LARGE_ARRAY_SIZE), + filterCount = 0, + mapCount = 0; + + var iteratee = function(value) { + mapCount++; + return value * value; + }; + + var predicate = function(value) { + filterCount++; + return isEven(value); + }; + + var map1 = convert('map', _.map), + filter1 = convert('filter', _.filter), + take1 = convert('take', _.take); + + var filter2 = filter1(predicate), + map2 = map1(iteratee), + take2 = take1(2); + + var combined = fp.flow(map2, filter2, fp.compact, take2); + + assert.deepEqual(combined(array), [4, 16]); + assert.strictEqual(filterCount, 200, 'filterCount'); + assert.strictEqual(mapCount, 200, 'mapCount'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('iteratee shorthands'); + + (function() { + var objects = [{ 'a': 1, 'b': 2 }, { 'a': 3, 'b': 4 }]; + + QUnit.test('should work with "_.matches" shorthands', function(assert) { + assert.expect(1); + + assert.deepEqual(fp.filter({ 'a': 3 })(objects), [objects[1]]); + }); + + QUnit.test('should work with "_.matchesProperty" shorthands', function(assert) { + assert.expect(1); + + assert.deepEqual(fp.filter(['a', 3])(objects), [objects[1]]); + }); + + QUnit.test('should work with "_.property" shorthands', function(assert) { + assert.expect(1); + + assert.deepEqual(fp.map('a')(objects), [1, 3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('placeholder methods'); + + (function() { + QUnit.test('should use `fp` as the default placeholder', function(assert) { + assert.expect(3); + + var actual = fp.add(fp, 'b')('a'); + assert.strictEqual(actual, 'ab'); + + actual = fp.fill(fp, 2)(1, '*')([1, 2, 3]); + assert.deepEqual(actual, [1, '*', 3]); + + actual = fp.slice(fp, 2)(1)(['a', 'b', 'c']); + assert.deepEqual(actual, ['b']); + }); + + QUnit.test('should support `fp.placeholder`', function(assert) { + assert.expect(6); + + _.each([[], fp.__], function(ph) { + fp.placeholder = ph; + + var actual = fp.add(ph, 'b')('a'); + assert.strictEqual(actual, 'ab'); + + actual = fp.fill(ph, 2)(1, '*')([1, 2, 3]); + assert.deepEqual(actual, [1, '*', 3]); + + actual = fp.slice(ph, 2)(1)(['a', 'b', 'c']); + assert.deepEqual(actual, ['b']); + }); + }); + + _.forOwn(mapping.placeholder, function(truthy, methodName) { + var func = fp[methodName]; + + QUnit.test('`_.' + methodName + '` should have a `placeholder` property', function(assert) { + assert.expect(2); + + assert.ok(_.isObject(func.placeholder)); + assert.strictEqual(func.placeholder, fp.__); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('setter methods'); + + (function() { + QUnit.test('should only clone objects in `path`', function(assert) { + assert.expect(11); + + var object = { 'a': { 'b': 2, 'c': 3 }, 'd': { 'e': 4 } }, + value = _.cloneDeep(object), + actual = fp.set('a.b.c.d', 5, value); + + assert.ok(_.isObject(actual.a.b), 'fp.set'); + assert.ok(_.isNumber(actual.a.b), 'fp.set'); + + assert.strictEqual(actual.a.b.c.d, 5, 'fp.set'); + assert.strictEqual(actual.d, value.d, 'fp.set'); + + value = _.cloneDeep(object); + actual = fp.setWith(Object)('[0][1]')('a')(value); + + assert.deepEqual(actual[0], { '1': 'a' }, 'fp.setWith'); + + value = _.cloneDeep(object); + actual = fp.unset('a.b')(value); + + assert.notOk('b' in actual.a, 'fp.unset'); + assert.strictEqual(actual.a.c, value.a.c, 'fp.unset'); + + value = _.cloneDeep(object); + actual = fp.update('a.b')(square)(value); + + assert.strictEqual(actual.a.b, 4, 'fp.update'); + assert.strictEqual(actual.d, value.d, 'fp.update'); + + value = _.cloneDeep(object); + actual = fp.updateWith(Object)('[0][1]')(_.constant('a'))(value); + + assert.deepEqual(actual[0], { '1': 'a' }, 'fp.updateWith'); + assert.strictEqual(actual.d, value.d, 'fp.updateWith'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.add and fp.subtract'); + + _.each(['add', 'subtract'], function(methodName) { + var func = fp[methodName], + isAdd = methodName == 'add'; + + QUnit.test('`fp.' + methodName + '` should not have `rearg` applied', function(assert) { + assert.expect(1); + + assert.strictEqual(func('1')('2'), isAdd ? '12' : -1); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('assign methods'); + + _.each(['assign', 'assignIn', 'defaults', 'defaultsDeep', 'merge'], function(methodName) { + var func = fp[methodName]; + + QUnit.test('`fp.' + methodName + '` should not mutate values', function(assert) { + assert.expect(2); + + var object = { 'a': 1 }, + actual = func(object)({ 'b': 2 }); + + assert.deepEqual(object, { 'a': 1 }); + assert.deepEqual(actual, { 'a': 1, 'b': 2 }); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('assignWith methods'); + + _.each(['assignWith', 'assignInWith', 'extendWith'], function(methodName) { + var func = fp[methodName]; + + QUnit.test('`fp.' + methodName + '` should provide the correct `customizer` arguments', function(assert) { + assert.expect(1); + + var args; + + func(function() { + args || (args = _.map(arguments, _.cloneDeep)); + })({ 'a': 1 })({ 'b': 2 }); + + assert.deepEqual(args, [undefined, 2, 'b', { 'a': 1 }, { 'b': 2 }]); + }); + + QUnit.test('`fp.' + methodName + '` should not mutate values', function(assert) { + assert.expect(2); + + var object = { 'a': 1 }; + + var actual = func(function(objValue, srcValue) { + return srcValue; + })(object)({ 'b': 2 }); + + assert.deepEqual(object, { 'a': 1 }); + assert.deepEqual(actual, { 'a': 1, 'b': 2 }); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.castArray'); + + (function() { + QUnit.test('should shallow clone array values', function(assert) { + assert.expect(2); + + var array = [1], + actual = fp.castArray(array); + + assert.deepEqual(actual, array); + assert.notStrictEqual(actual, array); + }); + + QUnit.test('should not shallow clone non-array values', function(assert) { + assert.expect(2); + + var object = { 'a': 1 }, + actual = fp.castArray(object); + + assert.deepEqual(actual, [object]); + assert.strictEqual(actual[0], object); + }); + + QUnit.test('should convert by name', function(assert) { + assert.expect(4); + + var array = [1], + object = { 'a': 1 }, + castArray = convert('castArray', _.castArray), + actual = castArray(array); + + assert.deepEqual(actual, array); + assert.notStrictEqual(actual, array); + + actual = castArray(object); + assert.deepEqual(actual, [object]); + assert.strictEqual(actual[0], object); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('curry methods'); + + _.each(['curry', 'curryRight'], function(methodName) { + var func = fp[methodName]; + + QUnit.test('`_.' + methodName + '` should only accept a `func` param', function(assert) { + assert.expect(1); + + assert.raises(function() { func(1, _.noop); }, TypeError); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('curryN methods'); + + _.each(['curryN', 'curryRightN'], function(methodName) { + var func = fp[methodName]; + + QUnit.test('`_.' + methodName + '` should accept an `arity` param', function(assert) { + assert.expect(1); + + var actual = func(1)(function(a, b) { return [a, b]; })('a'); + assert.deepEqual(actual, ['a', undefined]); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.difference'); + + (function() { + QUnit.test('should return the elements of the first array not included in the second array', function(assert) { + assert.expect(1); + + var actual = fp.difference([2, 1], [2, 3]); + assert.deepEqual(actual, [1]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.differenceBy'); + + (function() { + QUnit.test('should have an argument order of `iteratee`, `array`, then `values`', function(assert) { + assert.expect(1); + + var actual = fp.differenceBy(Math.floor, [2.1, 1.2], [2.3, 3.4]); + assert.deepEqual(actual, [1.2]); + }); + + QUnit.test('should provide the correct `iteratee` arguments', function(assert) { + assert.expect(1); + + var args; + + fp.differenceBy(function() { + args || (args = slice.call(arguments)); + })([2.1, 1.2], [2.3, 3.4]); + + assert.deepEqual(args, [2.3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.differenceWith'); + + (function() { + QUnit.test('should have an argument order of `comparator`, `array`, then `values`', function(assert) { + assert.expect(1); + + var actual = fp.differenceWith(fp.eq)([2, 1])([2, 3]); + assert.deepEqual(actual, [1]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.divide and fp.multiply'); + + _.each(['divide', 'multiply'], function(methodName) { + var func = fp[methodName], + isDivide = methodName == 'divide'; + + QUnit.test('`fp.' + methodName + '` should not have `rearg` applied', function(assert) { + assert.expect(1); + + assert.strictEqual(func('2')('4'), isDivide ? 0.5 : 8); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.extend'); + + (function() { + QUnit.test('should convert by name', function(assert) { + assert.expect(2); + + function Foo() {} + Foo.prototype = { 'b': 2 }; + + var object = { 'a': 1 }, + extend = convert('extend', _.extend), + value = _.clone(object), + actual = extend(value)(new Foo); + + assert.deepEqual(value, object); + assert.deepEqual(actual, { 'a': 1, 'b': 2 }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.fill'); + + (function() { + QUnit.test('should have an argument order of `start`, `end`, then `value`', function(assert) { + assert.expect(1); + + var array = [1, 2, 3]; + assert.deepEqual(fp.fill(1)(2)('*')(array), [1, '*', 3]); + }); + + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var array = [1, 2, 3], + actual = fp.fill(1)(2)('*')(array); + + assert.deepEqual(array, [1, 2, 3]); + assert.deepEqual(actual, [1, '*', 3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.findFrom methods'); + + _.each(['findFrom', 'findIndexFrom', 'findLastFrom', 'findLastIndexFrom'], function(methodName) { + var func = fp[methodName]; + + QUnit.test('`_.' + methodName + '` should provide the correct `predicate` arguments', function(assert) { + assert.expect(1); + + var args; + + func(function() { + args || (args = slice.call(arguments)); + })(1)([1, 2, 3]); + + assert.deepEqual(args, [2]); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.findFrom'); + + (function() { + function resolve(value) { + return fp.flow(fp.property('a'), fp.eq(value)); + } + + QUnit.test('should have an argument order of `value`, `fromIndex`, then `array`', function(assert) { + assert.expect(2); + + var objects = [{ 'a': 1 }, { 'a': 2 }, { 'a': 1 }, { 'a': 2 }]; + + assert.strictEqual(fp.findFrom(resolve(1))(1)(objects), objects[2]); + assert.strictEqual(fp.findFrom(resolve(2))(-2)(objects), objects[3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.findLastFrom'); + + (function() { + function resolve(value) { + return fp.flow(fp.property('a'), fp.eq(value)); + } + + QUnit.test('should have an argument order of `value`, `fromIndex`, then `array`', function(assert) { + assert.expect(2); + + var objects = [{ 'a': 1 }, { 'a': 2 }, { 'a': 1 }, { 'a': 2 }]; + + assert.strictEqual(fp.findLastFrom(resolve(1))(1)(objects), objects[0]); + assert.strictEqual(fp.findLastFrom(resolve(2))(-2)(objects), objects[1]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.findIndexFrom and fp.indexOfFrom'); + + _.each(['findIndexFrom', 'indexOfFrom'], function(methodName) { + var func = fp[methodName], + resolve = methodName == 'findIndexFrom' ? fp.eq : _.identity; + + QUnit.test('`_.' + methodName + '` should have an argument order of `value`, `fromIndex`, then `array`', function(assert) { + assert.expect(2); + + var array = [1, 2, 3, 1, 2, 3]; + + assert.deepEqual(func(resolve(1))(2)(array), 3); + assert.deepEqual(func(resolve(2))(-3)(array), 4); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.findLastIndexFrom and fp.lastIndexOfFrom'); + + _.each(['findLastIndexFrom', 'lastIndexOfFrom'], function(methodName) { + var func = fp[methodName], + resolve = methodName == 'findLastIndexFrom' ? fp.eq : _.identity; + + QUnit.test('`_.' + methodName + '` should have an argument order of `value`, `fromIndex`, then `array`', function(assert) { + assert.expect(2); + + var array = [1, 2, 3, 1, 2, 3]; + + assert.deepEqual(func(resolve(2))(3)(array), 1); + assert.deepEqual(func(resolve(3))(-3)(array), 2); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.flatMapDepth'); + + (function() { + QUnit.test('should have an argument order of `iteratee`, `depth`, then `collection`', function(assert) { + assert.expect(2); + + function duplicate(n) { + return [[[n, n]]]; + } + + var array = [1, 2], + object = { 'a': 1, 'b': 2 }, + expected = [[1, 1], [2, 2]]; + + assert.deepEqual(fp.flatMapDepth(duplicate)(2)(array), expected); + assert.deepEqual(fp.flatMapDepth(duplicate)(2)(object), expected); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('flow methods'); + + _.each(['flow', 'flowRight'], function(methodName) { + var func = fp[methodName], + isFlow = methodName == 'flow'; + + QUnit.test('`fp.' + methodName + '` should support shortcut fusion', function(assert) { + assert.expect(6); + + var filterCount, + mapCount, + array = fp.range(0, LARGE_ARRAY_SIZE); + + var iteratee = function(value) { + mapCount++; + return square(value); + }; + + var predicate = function(value) { + filterCount++; + return isEven(value); + }; + + var filter = fp.filter(predicate), + map = fp.map(iteratee), + take = fp.take(2); + + _.times(2, function(index) { + var combined = isFlow + ? func(map, filter, fp.compact, take) + : func(take, fp.compact, filter, map); + + filterCount = mapCount = 0; + + if (WeakMap && WeakMap.name) { + assert.deepEqual(combined(array), [4, 16]); + assert.strictEqual(filterCount, 5, 'filterCount'); + assert.strictEqual(mapCount, 5, 'mapCount'); + } + else { + skipAssert(assert, 3); + } + }); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('forEach methods'); + + _.each(['forEach', 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight'], function(methodName) { + var func = fp[methodName]; + + QUnit.test('`fp.' + methodName + '` should provide `value` to `iteratee`', function(assert) { + assert.expect(2); + + var args; + + func(function() { + args || (args = slice.call(arguments)); + })(['a']); + + assert.deepEqual(args, ['a']); + + args = undefined; + + func(function() { + args || (args = slice.call(arguments)); + })({ 'a': 1 }); + + assert.deepEqual(args, [1]); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.getOr'); + + (function() { + QUnit.test('should accept a `defaultValue` param', function(assert) { + assert.expect(1); + + var actual = fp.getOr('default')('path')({}); + assert.strictEqual(actual, 'default'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.gt and fp.gte'); + + _.each(['gt', 'gte'], function(methodName) { + var func = fp[methodName]; + + QUnit.test('`fp.' + methodName + '` should have `rearg` applied', function(assert) { + assert.expect(1); + + assert.strictEqual(func(2)(1), true); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.inRange'); + + (function() { + QUnit.test('should have an argument order of `start`, `end`, then `value`', function(assert) { + assert.expect(2); + + assert.strictEqual(fp.inRange(2)(4)(3), true); + assert.strictEqual(fp.inRange(-2)(-6)(-3), true); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.intersectionBy'); + + (function() { + QUnit.test('should have an argument order of `iteratee`, `array`, then `values`', function(assert) { + assert.expect(1); + + var actual = fp.intersectionBy(Math.floor, [2.1, 1.2], [2.3, 3.4]); + assert.deepEqual(actual, [2.1]); + }); + + QUnit.test('should provide the correct `iteratee` arguments', function(assert) { + assert.expect(1); + + var args; + + fp.intersectionBy(function() { + args || (args = slice.call(arguments)); + })([2.1, 1.2], [2.3, 3.4]); + + assert.deepEqual(args, [2.3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.intersectionWith'); + + (function() { + QUnit.test('should have an argument order of `comparator`, `array`, then `values`', function(assert) { + assert.expect(1); + + var actual = fp.intersectionWith(fp.eq)([2, 1])([2, 3]); + assert.deepEqual(actual, [2]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.invoke'); + + (function() { + QUnit.test('should not accept an `args` param', function(assert) { + assert.expect(1); + + var actual = fp.invoke('toUpperCase')('a'); + assert.strictEqual(actual, 'A'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.invokeMap'); + + (function() { + QUnit.test('should not accept an `args` param', function(assert) { + assert.expect(1); + + var actual = fp.invokeMap('toUpperCase')(['a', 'b']); + assert.deepEqual(actual, ['A', 'B']); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.invokeArgs'); + + (function() { + QUnit.test('should accept an `args` param', function(assert) { + assert.expect(1); + + var actual = fp.invokeArgs('concat')(['b', 'c'])('a'); + assert.strictEqual(actual, 'abc'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.invokeArgsMap'); + + (function() { + QUnit.test('should accept an `args` param', function(assert) { + assert.expect(1); + + var actual = fp.invokeArgsMap('concat')(['b', 'c'])(['a', 'A']); + assert.deepEqual(actual, ['abc', 'Abc']); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.isEqualWith'); + + (function() { + QUnit.test('should provide the correct `customizer` arguments', function(assert) { + assert.expect(1); + + var args, + iteration = 0, + objects = [{ 'a': 1 }, { 'a': 2 }], + stack = { '__data__': { '__data__': [objects] } }, + expected = [1, 2, 'a', objects[0], objects[1], stack]; + + fp.isEqualWith(function() { + if (++iteration == 2) { + args = _.map(arguments, _.cloneDeep); + } + })(objects[0])(objects[1]); + + args[5] = _.omitBy(args[5], _.isFunction); + args[5].__data__ = _.omitBy(args[5].__data__, _.isFunction); + + assert.deepEqual(args, expected); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.isMatchWith'); + + (function() { + QUnit.test('should provide the correct `customizer` arguments', function(assert) { + assert.expect(1); + + var args, + objects = [{ 'a': 1 }, { 'a': 2 }], + stack = { '__data__': { '__data__': [] } }, + expected = [2, 1, 'a', objects[1], objects[0], stack]; + + fp.isMatchWith(function() { + args || (args = _.map(arguments, _.cloneDeep)); + })(objects[0])(objects[1]); + + args[5] = _.omitBy(args[5], _.isFunction); + args[5].__data__ = _.omitBy(args[5].__data__, _.isFunction); + + assert.deepEqual(args, expected); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.iteratee'); + + (function() { + QUnit.test('should return a iteratee with capped params', function(assert) { + assert.expect(1); + + var func = fp.iteratee(function(a, b, c) { return [a, b, c]; }, 3); + assert.deepEqual(func(1, 2, 3), [1, undefined, undefined]); + }); + + QUnit.test('should convert by name', function(assert) { + assert.expect(1); + + var iteratee = convert('iteratee', _.iteratee), + func = iteratee(function(a, b, c) { return [a, b, c]; }, 3); + + assert.deepEqual(func(1, 2, 3), [1, undefined, undefined]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.lt and fp.lte'); + + _.each(['lt', 'lte'], function(methodName) { + var func = fp[methodName]; + + QUnit.test('`fp.' + methodName + '` should have `rearg` applied', function(assert) { + assert.expect(1); + + assert.strictEqual(func(1)(2), true); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.mapKeys'); + + (function() { + QUnit.test('should only provide `key` to `iteratee`', function(assert) { + assert.expect(1); + + var args; + + fp.mapKeys(function() { + args || (args = slice.call(arguments)); + }, { 'a': 1 }); + + assert.deepEqual(args, ['a']); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.maxBy and fp.minBy'); + + _.each(['maxBy', 'minBy'], function(methodName) { + var array = [1, 2, 3], + func = fp[methodName], + isMax = methodName == 'maxBy'; + + QUnit.test('`fp.' + methodName + '` should work with an `iteratee` argument', function(assert) { + assert.expect(1); + + var actual = func(function(num) { + return -num; + })(array); + + assert.strictEqual(actual, isMax ? 1 : 3); + }); + + QUnit.test('`fp.' + methodName + '` should provide the correct `iteratee` arguments', function(assert) { + assert.expect(1); + + var args; + + func(function() { + args || (args = slice.call(arguments)); + })(array); + + assert.deepEqual(args, [1]); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.mergeWith'); + + (function() { + QUnit.test('should provide the correct `customizer` arguments', function(assert) { + assert.expect(1); + + var args, + stack = { '__data__': { '__data__': [] } }, + expected = [[1], [2, 3], 'a', { 'a': [1] }, { 'a': [2, 3] }, stack]; + + fp.mergeWith(function() { + args || (args = _.map(arguments, _.cloneDeep)); + })({ 'a': [1] })({ 'a': [2, 3] }); + + args[5] = _.omitBy(args[5], _.isFunction); + args[5].__data__ = _.omitBy(args[5].__data__, _.isFunction); + + assert.deepEqual(args, expected); + }); + + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var object = { 'a': { 'b': 2, 'c': 3 } }; + object.a.b = [1]; + + var actual = fp.mergeWith(function(objValue, srcValue) { + if (_.isArray(objValue)) { + return objValue.concat(srcValue); + } + }, object, { 'a': { 'b': [2, 3] } }); + + assert.deepEqual(object, { 'a': { 'b': [1], 'c': 3 } }); + assert.deepEqual(actual, { 'a': { 'b': [1, 2, 3], 'c': 3 } }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.mixin'); + + (function() { + var source = { 'a': _.noop }; + + QUnit.test('should mixin static methods but not prototype methods', function(assert) { + assert.expect(2); + + fp.mixin(source); + + assert.strictEqual(typeof fp.a, 'function'); + assert.notOk('a' in fp.prototype); + + delete fp.a; + delete fp.prototype.a; + }); + + QUnit.test('should not assign inherited `source` methods', function(assert) { + assert.expect(2); + + function Foo() {} + Foo.prototype.a = _.noop; + fp.mixin(new Foo); + + assert.notOk('a' in fp); + assert.notOk('a' in fp.prototype); + + delete fp.a; + delete fp.prototype.a; + }); + + QUnit.test('should not remove existing prototype methods', function(assert) { + assert.expect(2); + + var each1 = fp.each, + each2 = fp.prototype.each; + + fp.mixin({ 'each': source.a }); + + assert.strictEqual(fp.each, source.a); + assert.strictEqual(fp.prototype.each, each2); + + fp.each = each1; + fp.prototype.each = each2; + }); + + QUnit.test('should not export to the global when `source` is not an object', function(assert) { + assert.expect(2); + + var props = _.without(_.keys(_), '_'); + + _.times(2, function(index) { + fp.mixin.apply(fp, index ? [1] : []); + + assert.ok(_.every(props, function(key) { + return root[key] !== fp[key]; + })); + + _.each(props, function(key) { + if (root[key] === fp[key]) { + delete root[key]; + } + }); + }); + }); + + QUnit.test('should convert by name', function(assert) { + assert.expect(3); + + var object = { 'mixin': convert('mixin', _.mixin) }; + + function Foo() {} + Foo.mixin = object.mixin; + Foo.mixin(source); + + assert.strictEqual(typeof Foo.a, 'function'); + assert.notOk('a' in Foo.prototype); + + object.mixin(source); + assert.strictEqual(typeof object.a, 'function'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.over'); + + (function() { + QUnit.test('should not cap iteratee args', function(assert) { + assert.expect(2); + + _.each([fp.over, convert('over', _.over)], function(func) { + var over = func([Math.max, Math.min]); + assert.deepEqual(over(1, 2, 3, 4), [4, 1]); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.omitBy and fp.pickBy'); + + _.each(['omitBy', 'pickBy'], function(methodName) { + var func = fp[methodName]; + + QUnit.test('`fp.' + methodName + '` should provide `value` and `key` to `iteratee`', function(assert) { + assert.expect(1); + + var args; + + func(function() { + args || (args = slice.call(arguments)); + })({ 'a': 1 }); + + assert.deepEqual(args, [1, 'a']); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('padChars methods'); + + _.each(['padChars', 'padCharsStart', 'padCharsEnd'], function(methodName) { + var func = fp[methodName], + isPad = methodName == 'padChars', + isStart = methodName == 'padCharsStart'; + + QUnit.test('`_.' + methodName + '` should truncate pad characters to fit the pad length', function(assert) { + assert.expect(1); + + if (isPad) { + assert.strictEqual(func('_-')(8)('abc'), '_-abc_-_'); + } else { + assert.strictEqual(func('_-')(6)('abc'), isStart ? '_-_abc' : 'abc_-_'); + } + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('partial methods'); + + _.each(['partial', 'partialRight'], function(methodName) { + var func = fp[methodName], + isPartial = methodName == 'partial'; + + QUnit.test('`_.' + methodName + '` should accept an `args` param', function(assert) { + assert.expect(1); + + var expected = isPartial ? [1, 2, 3] : [0, 1, 2]; + + var actual = func(function(a, b, c) { + return [a, b, c]; + })([1, 2])(isPartial ? 3 : 0); + + assert.deepEqual(actual, expected); + }); + + QUnit.test('`_.' + methodName + '` should convert by name', function(assert) { + assert.expect(2); + + var expected = isPartial ? [1, 2, 3] : [0, 1, 2], + par = convert(methodName, _[methodName]), + ph = par.placeholder; + + var actual = par(function(a, b, c) { + return [a, b, c]; + })([1, 2])(isPartial ? 3 : 0); + + assert.deepEqual(actual, expected); + + actual = par(function(a, b, c) { + return [a, b, c]; + })([ph, 2])(isPartial ? 1 : 0, isPartial ? 3 : 1); + + assert.deepEqual(actual, expected); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.pull'); + + (function() { + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var array = [1, 2, 3], + actual = fp.pull(2)(array); + + assert.deepEqual(array, [1, 2, 3]); + assert.deepEqual(actual, [1, 3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.pullAll'); + + (function() { + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var array = [1, 2, 3], + actual = fp.pullAll([1, 3])(array); + + assert.deepEqual(array, [1, 2, 3]); + assert.deepEqual(actual, [2]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.pullAt'); + + (function() { + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var array = [1, 2, 3], + actual = fp.pullAt([0, 2])(array); + + assert.deepEqual(array, [1, 2, 3]); + assert.deepEqual(actual, [2]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.random'); + + (function() { + var array = Array(1000); + + QUnit.test('should support a `min` and `max` argument', function(assert) { + assert.expect(1); + + var min = 5, + max = 10; + + assert.ok(_.some(array, function() { + var result = fp.random(min)(max); + return result >= min && result <= max; + })); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.range'); + + (function() { + QUnit.test('should have an argument order of `start` then `end`', function(assert) { + assert.expect(1); + + assert.deepEqual(fp.range(1)(4), [1, 2, 3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('reduce methods'); + + _.each(['reduce', 'reduceRight'], function(methodName) { + var func = fp[methodName], + isReduce = methodName == 'reduce'; + + QUnit.test('`_.' + methodName + '` should provide the correct `iteratee` arguments when iterating an array', function(assert) { + assert.expect(1); + + var args; + + func(function() { + args || (args = slice.call(arguments)); + })(0)([1, 2, 3]); + + assert.deepEqual(args, isReduce ? [0, 1] : [0, 3]); + }); + + QUnit.test('`_.' + methodName + '` should provide the correct `iteratee` arguments when iterating an object', function(assert) { + assert.expect(1); + + var args, + object = { 'a': 1, 'b': 2 }, + isFIFO = _.keys(object)[0] == 'a'; + + var expected = isFIFO + ? (isReduce ? [0, 1] : [0, 2]) + : (isReduce ? [0, 2] : [0, 1]); + + func(function() { + args || (args = slice.call(arguments)); + })(0)(object); + + assert.deepEqual(args, expected); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.remove'); + + (function() { + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var array = [1, 2, 3], + actual = fp.remove(fp.eq(2))(array); + + assert.deepEqual(array, [1, 2, 3]); + assert.deepEqual(actual, [1, 3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.restFrom'); + + (function() { + QUnit.test('should accept a `start` param', function(assert) { + assert.expect(1); + + var actual = fp.restFrom(2)(function() { + return slice.call(arguments); + })('a', 'b', 'c', 'd'); + + assert.deepEqual(actual, ['a', 'b', ['c', 'd']]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.reverse'); + + (function() { + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var array = [1, 2, 3], + actual = fp.reverse(array); + + assert.deepEqual(array, [1, 2, 3]); + assert.deepEqual(actual, [3, 2, 1]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.runInContext'); + + (function() { + QUnit.test('should return a converted lodash instance', function(assert) { + assert.expect(1); + + assert.strictEqual(typeof fp.runInContext({}).curryN, 'function'); + }); + + QUnit.test('should convert by name', function(assert) { + assert.expect(1); + + var runInContext = convert('runInContext', _.runInContext); + assert.strictEqual(typeof runInContext({}).curryN, 'function'); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.set'); + + (function() { + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var object = { 'a': { 'b': 2, 'c': 3 } }, + actual = fp.set('a.b')(3)(object); + + assert.deepEqual(object, { 'a': { 'b': 2, 'c': 3 } }); + assert.deepEqual(actual, { 'a': { 'b': 3, 'c': 3 } }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.setWith'); + + (function() { + QUnit.test('should provide the correct `customizer` arguments', function(assert) { + assert.expect(1); + + var args; + + fp.setWith(function() { + args || (args = _.map(arguments, _.cloneDeep)); + })('b.c')(2)({ 'a': 1 }); + + assert.deepEqual(args, [undefined, 'b', { 'a': 1 }]); + }); + + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var object = { 'a': { 'b': 2, 'c': 3 } }, + actual = fp.setWith(Object)('d.e')(4)(object); + + assert.deepEqual(object, { 'a': { 'b': 2, 'c': 3 } }); + assert.deepEqual(actual, { 'a': { 'b': 2, 'c': 3 }, 'd': { 'e': 4 } }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.spreadFrom'); + + (function() { + QUnit.test('should accept a `start` param', function(assert) { + assert.expect(1); + + var actual = fp.spreadFrom(2)(function() { + return slice.call(arguments); + })('a', 'b', ['c', 'd']); + + assert.deepEqual(actual, ['a', 'b', 'c', 'd']); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('trimChars methods'); + + _.each(['trimChars', 'trimCharsStart', 'trimCharsEnd'], function(methodName, index) { + var func = fp[methodName], + parts = []; + + if (index != 2) { + parts.push('leading'); + } + if (index != 1) { + parts.push('trailing'); + } + parts = parts.join(' and '); + + QUnit.test('`_.' + methodName + '` should remove ' + parts + ' `chars`', function(assert) { + assert.expect(1); + + var string = '-_-a-b-c-_-', + expected = (index == 2 ? '-_-' : '') + 'a-b-c' + (index == 1 ? '-_-' : ''); + + assert.strictEqual(func('_-')(string), expected); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.unionBy'); + + (function() { + QUnit.test('should have an argument order of `iteratee`, `array`, then `other`', function(assert) { + assert.expect(1); + + var actual = fp.unionBy(Math.floor, [2.1], [1.2, 2.3]); + assert.deepEqual(actual, [2.1, 1.2]); + }); + + QUnit.test('should provide the correct `iteratee` arguments', function(assert) { + assert.expect(1); + + var args; + + fp.unionBy(function() { + args || (args = slice.call(arguments)); + })([2.1], [1.2, 2.3]); + + assert.deepEqual(args, [2.1]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.unionWith'); + + (function() { + QUnit.test('should have an argument order of `comparator`, `array`, then `values`', function(assert) { + assert.expect(1); + + var actual = fp.unionWith(fp.eq)([2, 1])([2, 3]); + assert.deepEqual(actual, [2, 1, 3]); + }); + + QUnit.test('should provide the correct `comparator` arguments', function(assert) { + assert.expect(1); + + var args; + + fp.unionWith(function() { + args || (args = slice.call(arguments)); + })([2, 1])([2, 3]); + + assert.deepEqual(args, [1, 2]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.uniqBy'); + + (function() { + var objects = [{ 'a': 2 }, { 'a': 3 }, { 'a': 1 }, { 'a': 2 }, { 'a': 3 }, { 'a': 1 }]; + + QUnit.test('should work with an `iteratee` argument', function(assert) { + assert.expect(1); + + var expected = objects.slice(0, 3); + + var actual = fp.uniqBy(function(object) { + return object.a; + })(objects); + + assert.deepEqual(actual, expected); + }); + + QUnit.test('should provide the correct `iteratee` arguments', function(assert) { + assert.expect(1); + + var args; + + fp.uniqBy(function() { + args || (args = slice.call(arguments)); + })(objects); + + assert.deepEqual(args, [objects[0]]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.uniqWith'); + + (function() { + QUnit.test('should have an argument order of `comparator`, `array`, then `values`', function(assert) { + assert.expect(1); + + var actual = fp.uniqWith(fp.eq)([2, 1, 2]); + assert.deepEqual(actual, [2, 1]); + }); + + QUnit.test('should provide the correct `comparator` arguments', function(assert) { + assert.expect(1); + + var args; + + fp.uniqWith(function() { + args || (args = slice.call(arguments)); + })([2, 1, 2]); + + assert.deepEqual(args, [1, 2]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.update'); + + (function() { + QUnit.test('should not convert end of `path` to an object', function(assert) { + assert.expect(1); + + var actual = fp.update('a.b')(_.identity)({ 'a': { 'b': 1 } }); + assert.strictEqual(typeof actual.a.b, 'number'); + }); + + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var object = { 'a': { 'b': 2, 'c': 3 } }, + actual = fp.update('a.b')(square)(object); + + assert.deepEqual(object, { 'a': { 'b': 2, 'c': 3 } }); + assert.deepEqual(actual, { 'a': { 'b': 4, 'c': 3 } }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.updateWith'); + + (function() { + QUnit.test('should provide the correct `customizer` arguments', function(assert) { + var args; + + fp.updateWith(function() { + args || (args = _.map(arguments, _.cloneDeep)); + })('b.c')(_.constant(2))({ 'a': 1 }); + + assert.deepEqual(args, [undefined, 'b', { 'a': 1 }]); + }); + + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var object = { 'a': { 'b': 2, 'c': 3 } }, + actual = fp.updateWith(Object)('d.e')(_.constant(4))(object); + + assert.deepEqual(object, { 'a': { 'b': 2, 'c': 3 } }); + assert.deepEqual(actual, { 'a': { 'b': 2, 'c': 3 }, 'd': { 'e': 4 } }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.unset'); + + (function() { + QUnit.test('should not mutate values', function(assert) { + assert.expect(2); + + var object = { 'a': { 'b': 2, 'c': 3 } }, + actual = fp.unset('a.b')(object); + + assert.deepEqual(object, { 'a': { 'b': 2, 'c': 3 } }); + assert.deepEqual(actual, { 'a': { 'c': 3 } }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.xorBy'); + + (function() { + QUnit.test('should have an argument order of `iteratee`, `array`, then `other`', function(assert) { + assert.expect(1); + + var actual = fp.xorBy(Math.floor, [2.1, 1.2], [2.3, 3.4]); + assert.deepEqual(actual, [1.2, 3.4]); + }); + + QUnit.test('should provide the correct `iteratee` arguments', function(assert) { + assert.expect(1); + + var args; + + fp.xorBy(function() { + args || (args = slice.call(arguments)); + })([2.1, 1.2], [2.3, 3.4]); + + assert.deepEqual(args, [2.3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.xorWith'); + + (function() { + QUnit.test('should have an argument order of `comparator`, `array`, then `values`', function(assert) { + assert.expect(1); + + var actual = fp.xorWith(fp.eq)([2, 1])([2, 3]); + assert.deepEqual(actual, [1, 3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('with methods'); + + _.each(['differenceWith', 'intersectionWith', 'xorWith'], function(methodName) { + var func = fp[methodName]; + + QUnit.test('`fp.' + methodName + '` should provide the correct `comparator` arguments', function(assert) { + assert.expect(1); + + var args; + + func(function() { + args || (args = slice.call(arguments)); + })([2, 1])([2, 3]); + + assert.deepEqual(args, [2, 2]); + }); + }); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.zip'); + + (function() { + QUnit.test('should zip together two arrays', function(assert) { + assert.expect(1); + + assert.deepEqual(fp.zip([1, 2])([3, 4]), [[1, 3], [2, 4]]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.zipObject'); + + (function() { + QUnit.test('should zip together key/value arrays into an object', function(assert) { + assert.expect(1); + + assert.deepEqual(fp.zipObject(['a', 'b'])([1, 2]), { 'a': 1, 'b': 2 }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.zipWith'); + + (function() { + QUnit.test('should zip arrays combining grouped elements with `iteratee`', function(assert) { + assert.expect(1); + + var array1 = [1, 2, 3], + array2 = [4, 5, 6], + actual = fp.zipWith(add)(array1)(array2); + + assert.deepEqual(actual, [5, 7, 9]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.config.asyncRetries = 10; + QUnit.config.hidepassed = true; + + if (!document) { + QUnit.config.noglobals = true; + QUnit.load(); + } +}.call(this)); diff --git a/ecomp-portal-FE/client/bower_components/lodash/test/test.js b/ecomp-portal-FE/client/bower_components/lodash/test/test.js new file mode 100644 index 00000000..b979b622 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/lodash/test/test.js @@ -0,0 +1,26729 @@ +;(function() { + + /** Used as a safe reference for `undefined` in pre-ES5 environments. */ + var undefined; + + /** Used to detect when a function becomes hot. */ + var HOT_COUNT = 150; + + /** Used as the size to cover large array optimizations. */ + var LARGE_ARRAY_SIZE = 200; + + /** Used as the `TypeError` message for "Functions" methods. */ + var FUNC_ERROR_TEXT = 'Expected a function'; + + /** Used as references for various `Number` constants. */ + var MAX_SAFE_INTEGER = 9007199254740991, + MAX_INTEGER = 1.7976931348623157e+308; + + /** Used as references for the maximum length and index of an array. */ + var MAX_ARRAY_LENGTH = 4294967295, + MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; + + /** `Object#toString` result references. */ + var funcTag = '[object Function]', + numberTag = '[object Number]', + objectTag = '[object Object]'; + + /** Used as a reference to the global object. */ + var root = (typeof global == 'object' && global) || this; + + /** Used to store lodash to test for bad extensions/shims. */ + var lodashBizarro = root.lodashBizarro; + + /** Used for native method references. */ + var arrayProto = Array.prototype, + funcProto = Function.prototype, + objectProto = Object.prototype, + numberProto = Number.prototype, + stringProto = String.prototype; + + /** Method and object shortcuts. */ + var phantom = root.phantom, + process = root.process, + amd = root.define && define.amd, + argv = process && process.argv, + defineProperty = Object.defineProperty, + document = !phantom && root.document, + body = root.document && root.document.body, + create = Object.create, + fnToString = funcProto.toString, + freeze = Object.freeze, + getSymbols = Object.getOwnPropertySymbols, + identity = function(value) { return value; }, + JSON = root.JSON, + noop = function() {}, + objToString = objectProto.toString, + params = argv, + push = arrayProto.push, + realm = {}, + slice = arrayProto.slice; + + var ArrayBuffer = root.ArrayBuffer, + Buffer = root.Buffer, + Promise = root.Promise, + Map = root.Map, + Set = root.Set, + Symbol = root.Symbol, + Uint8Array = root.Uint8Array, + WeakMap = root.WeakMap, + WeakSet = root.WeakSet; + + var arrayBuffer = ArrayBuffer ? new ArrayBuffer(2) : undefined, + map = Map ? new Map : undefined, + promise = Promise ? Promise.resolve(1) : undefined, + set = Set ? new Set : undefined, + symbol = Symbol ? Symbol('a') : undefined, + weakMap = WeakMap ? new WeakMap : undefined, + weakSet = WeakSet ? new WeakSet : undefined; + + /** Math helpers. */ + var add = function(x, y) { return x + y; }, + doubled = function(n) { return n * 2; }, + isEven = function(n) { return n % 2 == 0; }, + square = function(n) { return n * n; }; + + /** Stub functions. */ + var stubA = function() { return 'a'; }, + stubB = function() { return 'b'; }, + stubC = function() { return 'c'; }; + + var stubTrue = function() { return true; }, + stubFalse = function() { return false; }; + + var stubNaN = function() { return NaN; }, + stubNull = function() { return null; }; + + var stubZero = function() { return 0; }, + stubOne = function() { return 1; }, + stubTwo = function() { return 2; }, + stubThree = function() { return 3; }, + stubFour = function() { return 4; }; + + var stubArray = function() { return []; }, + stubObject = function() { return {}; }, + stubString = function() { return ''; }; + + /** List of latin-1 supplementary letters to basic latin letters. */ + var burredLetters = [ + '\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7', '\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', + '\xcf', '\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', + '\xdf', '\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7', '\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', + '\xef', '\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' + ]; + + /** List of combining diacritical marks. */ + var comboMarks = [ + '\u0300', '\u0301', '\u0302', '\u0303', '\u0304', '\u0305', '\u0306', '\u0307', '\u0308', '\u0309', '\u030a', '\u030b', '\u030c', '\u030d', '\u030e', '\u030f', + '\u0310', '\u0311', '\u0312', '\u0313', '\u0314', '\u0315', '\u0316', '\u0317', '\u0318', '\u0319', '\u031a', '\u031b', '\u031c', '\u031d', '\u031e', '\u031f', + '\u0320', '\u0321', '\u0322', '\u0323', '\u0324', '\u0325', '\u0326', '\u0327', '\u0328', '\u0329', '\u032a', '\u032b', '\u032c', '\u032d', '\u032e', '\u032f', + '\u0330', '\u0331', '\u0332', '\u0333', '\u0334', '\u0335', '\u0336', '\u0337', '\u0338', '\u0339', '\u033a', '\u033b', '\u033c', '\u033d', '\u033e', '\u033f', + '\u0340', '\u0341', '\u0342', '\u0343', '\u0344', '\u0345', '\u0346', '\u0347', '\u0348', '\u0349', '\u034a', '\u034b', '\u034c', '\u034d', '\u034e', '\u034f', + '\u0350', '\u0351', '\u0352', '\u0353', '\u0354', '\u0355', '\u0356', '\u0357', '\u0358', '\u0359', '\u035a', '\u035b', '\u035c', '\u035d', '\u035e', '\u035f', + '\u0360', '\u0361', '\u0362', '\u0363', '\u0364', '\u0365', '\u0366', '\u0367', '\u0368', '\u0369', '\u036a', '\u036b', '\u036c', '\u036d', '\u036e', '\u036f', + '\ufe20', '\ufe21', '\ufe22', '\ufe23' + ]; + + /** List of `burredLetters` translated to basic latin letters. */ + var deburredLetters = [ + 'A', 'A', 'A', 'A', 'A', 'A', 'Ae', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', + 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 'Th', + 'ss', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', + 'i', 'd', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'th', 'y' + ]; + + /** Used to provide falsey values to methods. */ + var falsey = [, null, undefined, false, 0, NaN, '']; + + /** Used to specify the emoji style glyph variant of characters. */ + var emojiVar = '\ufe0f'; + + /** Used to provide empty values to methods. */ + var empties = [[], {}].concat(falsey.slice(1)); + + /** Used to test error objects. */ + var errors = [ + new Error, + new EvalError, + new RangeError, + new ReferenceError, + new SyntaxError, + new TypeError, + new URIError + ]; + + /** List of fitzpatrick modifiers. */ + var fitzModifiers = [ + '\ud83c\udffb', + '\ud83c\udffc', + '\ud83c\udffd', + '\ud83c\udffe', + '\ud83c\udfff' + ]; + + /** Used to provide primitive values to methods. */ + var primitives = [null, undefined, false, true, 1, NaN, 'a']; + + /** Used to check whether methods support typed arrays. */ + var typedArrays = [ + 'Float32Array', + 'Float64Array', + 'Int8Array', + 'Int16Array', + 'Int32Array', + 'Uint8Array', + 'Uint8ClampedArray', + 'Uint16Array', + 'Uint32Array' + ]; + + /** Used to check whether methods support array views. */ + var arrayViews = typedArrays.concat('DataView'); + + /** The file path of the lodash file to test. */ + var filePath = (function() { + var min = 2, + result = params || []; + + if (phantom) { + min = 0; + result = params = phantom.args || require('system').args; + } + var last = result[result.length - 1]; + result = (result.length > min && !/test(?:\.js)?$/.test(last)) ? last : '../lodash.js'; + + if (!amd) { + try { + result = require('fs').realpathSync(result); + } catch (e) {} + + try { + result = require.resolve(result); + } catch (e) {} + } + return result; + }()); + + /** The `ui` object. */ + var ui = root.ui || (root.ui = { + 'buildPath': filePath, + 'loaderPath': '', + 'isModularize': /\b(?:amd|commonjs|es|node|npm|(index|main)\.js)\b/.test(filePath), + 'isStrict': /\bes\b/.test(filePath) || 'default' in require(filePath), + 'urlParams': {} + }); + + /** The basename of the lodash file to test. */ + var basename = /[\w.-]+$/.exec(filePath)[0]; + + /** Used to indicate testing a modularized build. */ + var isModularize = ui.isModularize; + + /** Detect if testing `npm` modules. */ + var isNpm = isModularize && /\bnpm\b/.test([ui.buildPath, ui.urlParams.build]); + + /** Detect if running in PhantomJS. */ + var isPhantom = phantom || (typeof callPhantom == 'function'); + + /** Detect if lodash is in strict mode. */ + var isStrict = ui.isStrict; + + /*--------------------------------------------------------------------------*/ + + // Leak to avoid sporadic `noglobals` fails on Edge in Sauce Labs. + root.msWDfn = undefined; + + // Assign `setTimeout` to itself to avoid being flagged as a leak. + setProperty(root, 'setTimeout', setTimeout); + + // Exit early if going to run tests in a PhantomJS web page. + if (phantom && isModularize) { + var page = require('webpage').create(); + + page.onCallback = function(details) { + var coverage = details.coverage; + if (coverage) { + var fs = require('fs'), + cwd = fs.workingDirectory, + sep = fs.separator; + + fs.write([cwd, 'coverage', 'coverage.json'].join(sep), JSON.stringify(coverage)); + } + phantom.exit(details.failed ? 1 : 0); + }; + + page.onConsoleMessage = function(message) { + console.log(message); + }; + + page.onInitialized = function() { + page.evaluate(function() { + document.addEventListener('DOMContentLoaded', function() { + QUnit.done(function(details) { + details.coverage = window.__coverage__; + callPhantom(details); + }); + }); + }); + }; + + page.open(filePath, function(status) { + if (status != 'success') { + console.log('PhantomJS failed to load page: ' + filePath); + phantom.exit(1); + } + }); + + console.log('test.js invoked with arguments: ' + JSON.stringify(slice.call(params))); + return; + } + + /*--------------------------------------------------------------------------*/ + + /** Used to test Web Workers. */ + var Worker = !(ui.isForeign || ui.isSauceLabs || isModularize) && + (document && document.origin != 'null') && root.Worker; + + /** Used to test host objects in IE. */ + try { + var xml = new ActiveXObject('Microsoft.XMLDOM'); + } catch (e) {} + + /** Poison the free variable `root` in Node.js */ + try { + defineProperty(global.root, 'root', { + 'configurable': false, + 'enumerable': false, + 'get': function() { throw new ReferenceError; } + }); + } catch (e) {} + + /** Load QUnit and extras. */ + var QUnit = root.QUnit || require('qunit-extras'); + + /** Load stable Lodash. */ + var lodashStable = root.lodashStable; + if (!lodashStable) { + try { + lodashStable = interopRequire('../node_modules/lodash/lodash.js'); + } catch (e) { + console.log('Error: The stable lodash dev dependency should be at least a version behind master branch.'); + return; + } + lodashStable = lodashStable.noConflict(); + } + + /** The `lodash` function to test. */ + var _ = root._ || (root._ = interopRequire(filePath)); + + /** Used to test pseudo private map caches. */ + var mapCaches = (function() { + var MapCache = _.memoize.Cache; + var result = { + 'Hash': new MapCache().__data__.hash.constructor, + 'MapCache': MapCache + }; + _.isMatchWith({ 'a': 1 }, { 'a': 1 }, function() { + var stack = lodashStable.last(arguments); + result.ListCache = stack.__data__.constructor; + result.Stack = stack.constructor; + }); + return result; + }()); + + /** Used to detect instrumented istanbul code coverage runs. */ + var coverage = root.__coverage__ || root[lodashStable.findKey(root, function(value, key) { + return /^(?:\$\$cov_\d+\$\$)$/.test(key); + })]; + + /** Used to test generator functions. */ + var generator = lodashStable.attempt(function() { + return Function('return function*(){}'); + }); + + /** Used to restore the `_` reference. */ + var oldDash = root._; + + /** + * Used to check for problems removing whitespace. For a whitespace reference, + * see [V8's unit test](https://code.google.com/p/v8/source/browse/branches/bleeding_edge/test/mjsunit/whitespaces.js). + */ + var whitespace = lodashStable.filter([ + // Basic whitespace characters. + ' ', '\t', '\x0b', '\f', '\xa0', '\ufeff', + + // Line terminators. + '\n', '\r', '\u2028', '\u2029', + + // Unicode category "Zs" space separators. + '\u1680', '\u180e', '\u2000', '\u2001', '\u2002', '\u2003', '\u2004', '\u2005', + '\u2006', '\u2007', '\u2008', '\u2009', '\u200a', '\u202f', '\u205f', '\u3000' + ], + function(chr) { return /\s/.exec(chr); }) + .join(''); + + /** + * Creates a custom error object. + * + * @private + * @constructor + * @param {string} message The error message. + */ + function CustomError(message) { + this.name = 'CustomError'; + this.message = message; + } + + CustomError.prototype = lodashStable.create(Error.prototype, { + 'constructor': CustomError + }); + + /** + * Removes all own enumerable string keyed properties from a given object. + * + * @private + * @param {Object} object The object to empty. + */ + function emptyObject(object) { + lodashStable.forOwn(object, function(value, key, object) { + delete object[key]; + }); + } + + /** + * Extracts the unwrapped value from its wrapper. + * + * @private + * @param {Object} wrapper The wrapper to unwrap. + * @returns {*} Returns the unwrapped value. + */ + function getUnwrappedValue(wrapper) { + var index = -1, + actions = wrapper.__actions__, + length = actions.length, + result = wrapper.__wrapped__; + + while (++index < length) { + var args = [result], + action = actions[index]; + + push.apply(args, action.args); + result = action.func.apply(action.thisArg, args); + } + return result; + } + + /** + * Loads the module of `id`. If the module has an `exports.default`, the + * exported default value is returned as the resolved module. + * + * @private + * @param {string} id The identifier of the module to resolve. + * @returns {*} Returns the resolved module. + */ + function interopRequire(id) { + var result = require(id); + return 'default' in result ? result['default'] : result; + } + + /** + * Sets a non-enumerable property value on `object`. + * + * Note: This function is used to avoid a bug in older versions of V8 where + * overwriting non-enumerable built-ins makes them enumerable. + * See https://code.google.com/p/v8/issues/detail?id=1623 + * + * @private + * @param {Object} object The object modify. + * @param {string} key The name of the property to set. + * @param {*} value The property value. + */ + function setProperty(object, key, value) { + try { + defineProperty(object, key, { + 'configurable': true, + 'enumerable': false, + 'writable': true, + 'value': value + }); + } catch (e) { + object[key] = value; + } + return object; + } + + /** + * Skips a given number of tests with a passing result. + * + * @private + * @param {Object} assert The QUnit assert object. + * @param {number} [count=1] The number of tests to skip. + */ + function skipAssert(assert, count) { + count || (count = 1); + while (count--) { + assert.ok(true, 'test skipped'); + } + } + + /*--------------------------------------------------------------------------*/ + + // Add bizarro values. + (function() { + if (document || (typeof require != 'function')) { + return; + } + var nativeString = fnToString.call(toString), + reToString = /toString/g; + + function createToString(funcName) { + return lodashStable.constant(nativeString.replace(reToString, funcName)); + } + + // Allow bypassing native checks. + setProperty(funcProto, 'toString', function wrapper() { + setProperty(funcProto, 'toString', fnToString); + var result = lodashStable.has(this, 'toString') ? this.toString() : fnToString.call(this); + setProperty(funcProto, 'toString', wrapper); + return result; + }); + + // Add prototype extensions. + funcProto._method = noop; + + // Set bad shims. + setProperty(Object, 'create', (function() { + function object() {} + return function(prototype) { + if (lodashStable.isObject(prototype)) { + object.prototype = prototype; + var result = new object; + object.prototype = undefined; + } + return result || {}; + }; + }())); + + setProperty(Object, 'getOwnPropertySymbols', undefined); + + var _propertyIsEnumerable = objectProto.propertyIsEnumerable; + setProperty(objectProto, 'propertyIsEnumerable', function(key) { + return !(key == 'valueOf' && this && this.valueOf === 1) && _propertyIsEnumerable.call(this, key); + }); + + if (Buffer) { + defineProperty(root, 'Buffer', { + 'configurable': true, + 'enumerable': true, + 'get': function get() { + var caller = get.caller, + name = caller ? caller.name : ''; + + if (!(name == 'runInContext' || name.length == 1 || /\b_\.isBuffer\b/.test(caller))) { + return Buffer; + } + } + }); + } + if (Map) { + setProperty(root, 'Map', (function() { + var count = 0; + return function() { + if (count++) { + return new Map; + } + setProperty(root, 'Map', Map); + return {}; + }; + }())); + + setProperty(root.Map, 'toString', createToString('Map')); + } + setProperty(root, 'Promise', noop); + setProperty(root, 'Set', noop); + setProperty(root, 'Symbol', undefined); + setProperty(root, 'WeakMap', noop); + + // Fake `WinRTError`. + setProperty(root, 'WinRTError', Error); + + // Clear cache so lodash can be reloaded. + emptyObject(require.cache); + + // Load lodash and expose it to the bad extensions/shims. + lodashBizarro = interopRequire(filePath); + root._ = oldDash; + + // Restore built-in methods. + setProperty(Object, 'create', create); + setProperty(objectProto, 'propertyIsEnumerable', _propertyIsEnumerable); + setProperty(root, 'Buffer', Buffer); + + if (getSymbols) { + Object.getOwnPropertySymbols = getSymbols; + } else { + delete Object.getOwnPropertySymbols; + } + if (Map) { + setProperty(root, 'Map', Map); + } else { + delete root.Map; + } + if (Promise) { + setProperty(root, 'Promise', Promise); + } else { + delete root.Promise; + } + if (Set) { + setProperty(root, 'Set', Set); + } else { + delete root.Set; + } + if (Symbol) { + setProperty(root, 'Symbol', Symbol); + } else { + delete root.Symbol; + } + if (WeakMap) { + setProperty(root, 'WeakMap', WeakMap); + } else { + delete root.WeakMap; + } + delete root.WinRTError; + delete funcProto._method; + }()); + + // Add other realm values from the `vm` module. + lodashStable.attempt(function() { + lodashStable.assign(realm, require('vm').runInNewContext([ + '(function() {', + ' var noop = function() {},', + ' root = this;', + '', + ' var object = {', + " 'ArrayBuffer': root.ArrayBuffer,", + " 'arguments': (function() { return arguments; }(1, 2, 3)),", + " 'array': [1],", + " 'arrayBuffer': root.ArrayBuffer ? new root.ArrayBuffer : undefined,", + " 'boolean': Object(false),", + " 'date': new Date,", + " 'errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],", + " 'function': noop,", + " 'map': root.Map ? new root.Map : undefined,", + " 'nan': NaN,", + " 'null': null,", + " 'number': Object(0),", + " 'object': { 'a': 1 },", + " 'promise': root.Promise ? Promise.resolve(1) : undefined,", + " 'regexp': /x/,", + " 'set': root.Set ? new root.Set : undefined,", + " 'string': Object('a'),", + " 'symbol': root.Symbol ? root.Symbol() : undefined,", + " 'undefined': undefined,", + " 'weakMap': root.WeakMap ? new root.WeakMap : undefined,", + " 'weakSet': root.WeakSet ? new root.WeakSet : undefined", + ' };', + '', + " ['" + arrayViews.join("', '") + "'].forEach(function(type) {", + ' var Ctor = root[type]', + ' object[type] = Ctor;', + ' object[type.toLowerCase()] = Ctor ? new Ctor(new ArrayBuffer(24)) : undefined;', + ' });', + '', + ' return object;', + '}())' + ].join('\n'))); + }); + + // Add other realm values from an iframe. + lodashStable.attempt(function() { + _._realm = realm; + + var iframe = document.createElement('iframe'); + iframe.frameBorder = iframe.height = iframe.width = 0; + body.appendChild(iframe); + + var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc; + idoc.write([ + ' + + + + + + + + + + + -- cgit 1.2.3-korg