<commit_before>module.exports = {
  classitems: [
    '$',
    'A',
    'EXTEND_PROTOTYPES',
    'GUID_KEY',
    'GUID_PREFIX',
    'LOG_STACKTRACE_ON_DEPRECATION',
    'LOG_VERSION',
    '[]',
    '_APPLICATION_TEMPLATE_WRAPPER',
    '_JQUERY_INTEGRATION',
    '_TEMPLATE_ONLY_GLIMMER_COMPONENTS',
    '__container__',
    '_activeQPChanged',
    '_applicationInstances',
    '_deserializeQueryParam',
    '_deserializeQueryParams',
    '_fullyScopeQueryParams',
    '_getHashPath',
    '_getObjectsOnNamespaces',
    '_getQPMeta',
    '_globalsMode',
    '_helpers',
    '_hydrateUnsuppliedQueryParams',
    '_initializersRan',
    '_injections',
    '_internalReset',
    '_invoke',
    '_lazyInjections',
    '_logLookup',
    '_names',
    '_normalizeCache',
    '_onLookup',
    '_options',
    '_optionsForQueryParam',
    '_prepareForGlobalsMode',
    '_prepareQueryParams',
    '_pruneDefaultQueryParamValues',
    '_qp',
    '_qpChanged',
    '_qpDelegate',
    '_queryParamsFor',
    '_renderMode',
    '_resolveCache',
    '_scheduledDestroy',
    '_serializeQueryParam',
    '_serializeQueryParams',
    '_setRouteName',
    '_stashNames',
    '_typeInjections',
    '_typeOptions',
    '_unwatchInstance',
    '_updatingQPChanged',
    '_watchInstance',
    'abort',
    'acceptsModelName',
    'action',
    'actions',
    'activate',
    'active',
    'activeClass',
    'adapter',
    'addArrayObserver',
    'addListener',
    'addObject',
    'addObjects',
    'addObserver',
    'advanceReadiness',
    'afterModel',
    'alias',
    'aliasMethod',
    'all',
    'allSettled',
    'and',
    'any',
    'append',
    'appendTo',
    'application',
    'apply',
    'ariaRole',
    'arrangedContent',
    'array',
    'arrayContentDidChange',
    'arrayContentWillChange',
    'assert',
    'assign',
    'asyncEnd',
    'asyncStart',
    'attributeBindings',
    'attributeLimit',
    'attributes',
    'autoboot',
    'beforeModel',
    'begin',
    'beginPropertyChanges',
    'bind',
    'bool',
    'boot',
    'bubbles',
    'buildChildEngineInstance',
    'buildInstance',
    'buildRegistry',
    'cache',
    'cacheFor',
    'camelize',
    'canCatalogEntriesByType',
    'canInvoke',
    'cancel',
    'cancelRouterSetup',
    'capitalize',
    'catalogEntriesByType',
    'catch',
    'changeProperties',
    'checkWaiters',
    'childViews',
    'classNameBindings',
    'classNames',
    'classify',
    'clear',
    'click',
    'cloneParentDependencies',
    'collect',
    'columnsForType',
    'compact',
    'compare',
    'component',
    'compute',
    'computed',
    'concat',
    'concatenatedProperties',
    'container',
    'containerDebugAdapter',
    'content',
    'contextDidChange',
    'controller',
    'controllerFor',
    'controllerName',
    'copy',
    'create',
    'current-when',
    'currentPath',
    'currentRoute',
    'currentRouteName',
    'currentURL',
    'customEvents',
    'dasherize',
    'data',
    'deactivate',
    'debounce',
    'debug',
    'debugger',
    'decamelize',
    'decrementProperty',
    'defer',
    'deferReadiness',
    'defineProperty',
    'deleteMeta',
    'denodeify',
    'deprecate',
    'deprecateFunc',
    'deprecateProperty',
    'deprecatingAlias',
    'describe',
    'descriptorFor',
    'deserialize',
    'deserializeQueryParam',
    'destroy',
    'detect',
    'didBecomeReady',
    'didInsertElement',
    'didReceiveAttrs',
    'didRender',
    'didTransition',
    'didUpdate',
    'didUpdateAttrs',
    'disabled',
    'disabledClass',
    'disconnectOutlet',
    'document',
    'domReady',
    'each',
    'each-in',
    'eachComputedProperty',
    'element',
    'elementId',
    'empty',
    'end',
    'endPropertyChanges',
    'engine',
    'ensureInitializers',
    'enter',
    'equal',
    'error',
    'eventDispatcher',
    'eventName',
    'events',
    'every',
    'exception',
    'exit',
    'expandLocalLookup',
    'expandProperties',
    'extend',
    'factoryFor',
    'fallback',
    'fillIn',
    'filter',
    'filterBy',
    'finally',
    'find',
    'findBy',
    'findElementInParentElement',
    'findModel',
    'findWithAssert',
    'firstObject',
    'focusIn',
    'focusOut',
    'followRedirects',
    'forEach',
    'formatURL',
    'from',
    'fullRouteName',
    'generateController',
    'generateControllerFactory',
    'generateGuid',
    'get',
    'getChildViews',
    'getEach',
    'getEngineParent',
    'getFilters',
    'getHash',
    'getModelTypes',
    'getOwner',
    'getProperties',
    'getRecordColor',
    'getRecordColumnValues',
    'getRecordFilterValues',
    'getRecordKeywords',
    'getRecords',
    'getRootViews',
    'getState',
    'getURL',
    'getViewBoundingClientRect',
    'getViewBounds',
    'getViewClientRects',
    'getViewElement',
    'getViewId',
    'getViewRange',
    'getWithDefault',
    'global',
    'gt',
    'gte',
    'guidFor',
    'handleEvent',
    'handleURL',
    'has',
    'hasArrayObservers',
    'hasListeners',
    'hasObserverFor',
    'hasRegistration',
    'hasRoute',
    'hash',
    'hashSettled',
    'helper',
    'helperContainer',
    'history',
    'href',
    'htmlSafe',
    'if',
    'includes',
    'incrementProperty',
    'indexOf',
    'info',
    'init',
    'initState',
    'initializer',
    'inject',
    'injectTestHelpers',
    'injection',
    'input',
    'insertAt',
    'insertNewline',
    'inspect',
    'instanceInitializer',
    'instrument',
    'intermediateTransitionTo',
    'intersect',
    'invoke',
    'isActive',
    'isActiveIntent',
    'isAny',
    'isArray',
    'isBlank',
    'isBrowser',
    'isDestroyed',
    'isDestroying',
    'isEmpty',
    'isEnabled',
    'isEqual',
    'isEvery',
    'isFulfilled',
    'isHTMLSafe',
    'isInteractive',
    'isNone',
    'isObject',
    'isPending',
    'isPresent',
    'isRejected',
    'isSettled',
    'isVisible',
    'jQuery',
    'join',
    'keyDown',
    'keyEvent',
    'keyPress',
    'keyUp',
    'knownForType',
    'lastIndexOf',
    'lastObject',
    'later',
    'layout',
    'layoutName',
    'length',
    'let',
    'link-to',
    'loading',
    'loadingClass',
    'loadingHref',
    'loc',
    'localName',
    'location',
    'log',
    'lookup',
    'lookupDescription',
    'lt',
    'lte',
    'makeArray',
    'makeToString',
    'map',
    'mapBy',
    'match',
    'matches',
    'max',
    'merge',
    'mergedProperties',
    'meta',
    'metadata',
    'metaForProperty',
    'method',
    'min',
    'mixin',
    'model',
    'modelFor',
    'mount',
    'mut',
    'name',
    'namespace',
    'nearestOfType',
    'nearestWithProperty',
    'next',
    'none',
    'normalize',
    'normalizeFullName',
    'not',
    'notEmpty',
    'notifyPropertyChange',
    'objectAt',
    'objectAtContent',
    'objectsAt',
    'observeModelType',
    'observer',
    'observerRecord',
    'observes',
    'off',
    'on',
    'onInjectHelpers',
    'onLoad',
    'onUpdateURL',
    'once',
    'one',
    'oneWay',
    'options',
    'optionsForType',
    'or',
    'originalMethods',
    'outlet',
    'ownerInjection',
    'paramNames',
    'params',
    'paramsFor',
    'parent',
    'parentView',
    'parentViewDidChange',
    'parseName',
    'partial',
    'pattern',
    'pauseTest',
    'popObject',
    'positionalParams',
    'promise',
    'property',
    'pushObject',
    'pushObjects',
    'pushState',
    'query-params',
    'queryParams',
    'queryParamsDidChange',
    'queues',
    'race',
    'readDOMAttr',
    'readOnly',
    'readonly',
    'reads',
    'ready',
    'reason',
    'recognize',
    'recognizeAndLoad',
    'recompute',
    'redirect',
    'reduce',
    'refresh',
    'register',
    'registerAsyncHelper',
    'registerDeprecationHandler',
    'registerHelper',
    'registerOptions',
    'registerOptionsForType',
    'registerWaiter',
    'registerWarnHandler',
    'registeredActions',
    'registeredOption',
    'registeredOptions',
    'registeredOptionsForType',
    'registrations',
    'registry',
    'reject',
    'rejectBy',
    'rel',
    'releaseMethods',
    'removeArrayObserver',
    'removeAt',
    'removeListener',
    'removeObject',
    'removeObjects',
    'removeObserver',
    'removeTestHelpers',
    'render',
    'renderTemplate',
    'reopen',
    'reopenClass',
    'replace',
    'replaceContent',
    'replaceRoute',
    'replaceState',
    'replaceURL',
    'replaceWith',
    'rerender',
    'reset',
    'resetController',
    'resolve',
    'resolveController',
    'resolveHelper',
    'resolveModel',
    'resolveOther',
    'resolveRegistration',
    'resolveRoute',
    'resolveTemplate',
    'resolveView',
    'resolver',
    'resolverFor',
    'resumeTest',
    'rethrow',
    'retry',
    'reverseObjects',
    'rootElement',
    'rootURL',
    'routeDidChange',
    'routeName',
    'routeWillChange',
    'run',
    'runInDebug',
    'runInitializers',
    'runInstanceInitializers',
    'runLoadHooks',
    'schedule',
    'scheduleOnce',
    'send',
    'sendAction',
    'sendEvent',
    'serialize',
    'serializeQueryParam',
    'serializeQueryParamKey',
    'set',
    'setDiff',
    'setEach',
    'setEngineParent',
    'setObjects',
    'setOwner',
    'setProperties',
    'setURL',
    'setup',
    'setupController',
    'setupForTesting',
    'setupHandler',
    'setupRegistry',
    'shiftObject',
    'shouldRender',
    'size',
    'slice',
    'sort',
    'sortBy',
    'startRouting',
    'store',
    'subscribe',
    'sum',
    'tabindex',
    'tagName',
    'target',
    'teardownViews',
    'templateName',
    'testCheckboxClick',
    'testHelpers',
    'testing',
    'textarea',
    'then',
    'throttle',
    'title',
    'to',
    'toArray',
    'toString',
    'toggleProperty',
    'transitionTo',
    'transitionToRoute',
    'translateToContainerFullname',
    'trigger',
    'triggerAction',
    'triggerEvent',
    'tryInvoke',
    'trySet',
    'type',
    'typeInjection',
    'typeOf',
    'unbound',
    'underscore',
    'union',
    'uniq',
    'uniqBy',
    'unless',
    'unregister',
    'unregisterHelper',
    'unregisterWaiter',
    'unshiftObject',
    'unshiftObjects',
    'unsubscribe',
    'unwatch',
    'url',
    'urlFor',
    'useRouterNaming',
    'userAgent',
    'validationCache',
    'value',
    'visit',
    'volatile',
    'w',
    'wait',
    'waitForDOMReady',
    'warn',
    'watch',
    'watchModelTypes',
    'watchRecords',
    'willClearRender',
    'willDestroy',
    'willDestroyElement',
    'willInsertElement',
    'willRender',
    'willTransition',
    'willUpdate',
    'with',
    'without',
    'wrap',
    'wrapModelType',
    'wrapRecord',
    'yield',
  ],
};
<commit_msg>added isDescriptor to classitems<commit_after>module.exports = {
  classitems: [
    '$',
    'A',
    'EXTEND_PROTOTYPES',
    'GUID_KEY',
    'GUID_PREFIX',
    'LOG_STACKTRACE_ON_DEPRECATION',
    'LOG_VERSION',
    '[]',
    '_APPLICATION_TEMPLATE_WRAPPER',
    '_JQUERY_INTEGRATION',
    '_TEMPLATE_ONLY_GLIMMER_COMPONENTS',
    '__container__',
    '_activeQPChanged',
    '_applicationInstances',
    '_deserializeQueryParam',
    '_deserializeQueryParams',
    '_fullyScopeQueryParams',
    '_getHashPath',
    '_getObjectsOnNamespaces',
    '_getQPMeta',
    '_globalsMode',
    '_helpers',
    '_hydrateUnsuppliedQueryParams',
    '_initializersRan',
    '_injections',
    '_internalReset',
    '_invoke',
    '_lazyInjections',
    '_logLookup',
    '_names',
    '_normalizeCache',
    '_onLookup',
    '_options',
    '_optionsForQueryParam',
    '_prepareForGlobalsMode',
    '_prepareQueryParams',
    '_pruneDefaultQueryParamValues',
    '_qp',
    '_qpChanged',
    '_qpDelegate',
    '_queryParamsFor',
    '_renderMode',
    '_resolveCache',
    '_scheduledDestroy',
    '_serializeQueryParam',
    '_serializeQueryParams',
    '_setRouteName',
    '_stashNames',
    '_typeInjections',
    '_typeOptions',
    '_unwatchInstance',
    '_updatingQPChanged',
    '_watchInstance',
    'abort',
    'acceptsModelName',
    'action',
    'actions',
    'activate',
    'active',
    'activeClass',
    'adapter',
    'addArrayObserver',
    'addListener',
    'addObject',
    'addObjects',
    'addObserver',
    'advanceReadiness',
    'afterModel',
    'alias',
    'aliasMethod',
    'all',
    'allSettled',
    'and',
    'any',
    'append',
    'appendTo',
    'application',
    'apply',
    'ariaRole',
    'arrangedContent',
    'array',
    'arrayContentDidChange',
    'arrayContentWillChange',
    'assert',
    'assign',
    'asyncEnd',
    'asyncStart',
    'attributeBindings',
    'attributeLimit',
    'attributes',
    'autoboot',
    'beforeModel',
    'begin',
    'beginPropertyChanges',
    'bind',
    'bool',
    'boot',
    'bubbles',
    'buildChildEngineInstance',
    'buildInstance',
    'buildRegistry',
    'cache',
    'cacheFor',
    'camelize',
    'canCatalogEntriesByType',
    'canInvoke',
    'cancel',
    'cancelRouterSetup',
    'capitalize',
    'catalogEntriesByType',
    'catch',
    'changeProperties',
    'checkWaiters',
    'childViews',
    'classNameBindings',
    'classNames',
    'classify',
    'clear',
    'click',
    'cloneParentDependencies',
    'collect',
    'columnsForType',
    'compact',
    'compare',
    'component',
    'compute',
    'computed',
    'concat',
    'concatenatedProperties',
    'container',
    'containerDebugAdapter',
    'content',
    'contextDidChange',
    'controller',
    'controllerFor',
    'controllerName',
    'copy',
    'create',
    'current-when',
    'currentPath',
    'currentRoute',
    'currentRouteName',
    'currentURL',
    'customEvents',
    'dasherize',
    'data',
    'deactivate',
    'debounce',
    'debug',
    'debugger',
    'decamelize',
    'decrementProperty',
    'defer',
    'deferReadiness',
    'defineProperty',
    'deleteMeta',
    'denodeify',
    'deprecate',
    'deprecateFunc',
    'deprecateProperty',
    'deprecatingAlias',
    'describe',
    'descriptorFor',
    'deserialize',
    'deserializeQueryParam',
    'destroy',
    'detect',
    'didBecomeReady',
    'didInsertElement',
    'didReceiveAttrs',
    'didRender',
    'didTransition',
    'didUpdate',
    'didUpdateAttrs',
    'disabled',
    'disabledClass',
    'disconnectOutlet',
    'document',
    'domReady',
    'each',
    'each-in',
    'eachComputedProperty',
    'element',
    'elementId',
    'empty',
    'end',
    'endPropertyChanges',
    'engine',
    'ensureInitializers',
    'enter',
    'equal',
    'error',
    'eventDispatcher',
    'eventName',
    'events',
    'every',
    'exception',
    'exit',
    'expandLocalLookup',
    'expandProperties',
    'extend',
    'factoryFor',
    'fallback',
    'fillIn',
    'filter',
    'filterBy',
    'finally',
    'find',
    'findBy',
    'findElementInParentElement',
    'findModel',
    'findWithAssert',
    'firstObject',
    'focusIn',
    'focusOut',
    'followRedirects',
    'forEach',
    'formatURL',
    'from',
    'fullRouteName',
    'generateController',
    'generateControllerFactory',
    'generateGuid',
    'get',
    'getChildViews',
    'getEach',
    'getEngineParent',
    'getFilters',
    'getHash',
    'getModelTypes',
    'getOwner',
    'getProperties',
    'getRecordColor',
    'getRecordColumnValues',
    'getRecordFilterValues',
    'getRecordKeywords',
    'getRecords',
    'getRootViews',
    'getState',
    'getURL',
    'getViewBoundingClientRect',
    'getViewBounds',
    'getViewClientRects',
    'getViewElement',
    'getViewId',
    'getViewRange',
    'getWithDefault',
    'global',
    'gt',
    'gte',
    'guidFor',
    'handleEvent',
    'handleURL',
    'has',
    'hasArrayObservers',
    'hasListeners',
    'hasObserverFor',
    'hasRegistration',
    'hasRoute',
    'hash',
    'hashSettled',
    'helper',
    'helperContainer',
    'history',
    'href',
    'htmlSafe',
    'if',
    'includes',
    'incrementProperty',
    'indexOf',
    'info',
    'init',
    'initState',
    'initializer',
    'inject',
    'injectTestHelpers',
    'injection',
    'input',
    'insertAt',
    'insertNewline',
    'inspect',
    'instanceInitializer',
    'instrument',
    'intermediateTransitionTo',
    'intersect',
    'invoke',
    'isActive',
    'isActiveIntent',
    'isAny',
    'isArray',
    'isBlank',
    'isBrowser',
    'isDescriptor',
    'isDestroyed',
    'isDestroying',
    'isEmpty',
    'isEnabled',
    'isEqual',
    'isEvery',
    'isFulfilled',
    'isHTMLSafe',
    'isInteractive',
    'isNone',
    'isObject',
    'isPending',
    'isPresent',
    'isRejected',
    'isSettled',
    'isVisible',
    'jQuery',
    'join',
    'keyDown',
    'keyEvent',
    'keyPress',
    'keyUp',
    'knownForType',
    'lastIndexOf',
    'lastObject',
    'later',
    'layout',
    'layoutName',
    'length',
    'let',
    'link-to',
    'loading',
    'loadingClass',
    'loadingHref',
    'loc',
    'localName',
    'location',
    'log',
    'lookup',
    'lookupDescription',
    'lt',
    'lte',
    'makeArray',
    'makeToString',
    'map',
    'mapBy',
    'match',
    'matches',
    'max',
    'merge',
    'mergedProperties',
    'meta',
    'metadata',
    'metaForProperty',
    'method',
    'min',
    'mixin',
    'model',
    'modelFor',
    'mount',
    'mut',
    'name',
    'namespace',
    'nearestOfType',
    'nearestWithProperty',
    'next',
    'none',
    'normalize',
    'normalizeFullName',
    'not',
    'notEmpty',
    'notifyPropertyChange',
    'objectAt',
    'objectAtContent',
    'objectsAt',
    'observeModelType',
    'observer',
    'observerRecord',
    'observes',
    'off',
    'on',
    'onInjectHelpers',
    'onLoad',
    'onUpdateURL',
    'once',
    'one',
    'oneWay',
    'options',
    'optionsForType',
    'or',
    'originalMethods',
    'outlet',
    'ownerInjection',
    'paramNames',
    'params',
    'paramsFor',
    'parent',
    'parentView',
    'parentViewDidChange',
    'parseName',
    'partial',
    'pattern',
    'pauseTest',
    'popObject',
    'positionalParams',
    'promise',
    'property',
    'pushObject',
    'pushObjects',
    'pushState',
    'query-params',
    'queryParams',
    'queryParamsDidChange',
    'queues',
    'race',
    'readDOMAttr',
    'readOnly',
    'readonly',
    'reads',
    'ready',
    'reason',
    'recognize',
    'recognizeAndLoad',
    'recompute',
    'redirect',
    'reduce',
    'refresh',
    'register',
    'registerAsyncHelper',
    'registerDeprecationHandler',
    'registerHelper',
    'registerOptions',
    'registerOptionsForType',
    'registerWaiter',
    'registerWarnHandler',
    'registeredActions',
    'registeredOption',
    'registeredOptions',
    'registeredOptionsForType',
    'registrations',
    'registry',
    'reject',
    'rejectBy',
    'rel',
    'releaseMethods',
    'removeArrayObserver',
    'removeAt',
    'removeListener',
    'removeObject',
    'removeObjects',
    'removeObserver',
    'removeTestHelpers',
    'render',
    'renderTemplate',
    'reopen',
    'reopenClass',
    'replace',
    'replaceContent',
    'replaceRoute',
    'replaceState',
    'replaceURL',
    'replaceWith',
    'rerender',
    'reset',
    'resetController',
    'resolve',
    'resolveController',
    'resolveHelper',
    'resolveModel',
    'resolveOther',
    'resolveRegistration',
    'resolveRoute',
    'resolveTemplate',
    'resolveView',
    'resolver',
    'resolverFor',
    'resumeTest',
    'rethrow',
    'retry',
    'reverseObjects',
    'rootElement',
    'rootURL',
    'routeDidChange',
    'routeName',
    'routeWillChange',
    'run',
    'runInDebug',
    'runInitializers',
    'runInstanceInitializers',
    'runLoadHooks',
    'schedule',
    'scheduleOnce',
    'send',
    'sendAction',
    'sendEvent',
    'serialize',
    'serializeQueryParam',
    'serializeQueryParamKey',
    'set',
    'setDiff',
    'setEach',
    'setEngineParent',
    'setObjects',
    'setOwner',
    'setProperties',
    'setURL',
    'setup',
    'setupController',
    'setupForTesting',
    'setupHandler',
    'setupRegistry',
    'shiftObject',
    'shouldRender',
    'size',
    'slice',
    'sort',
    'sortBy',
    'startRouting',
    'store',
    'subscribe',
    'sum',
    'tabindex',
    'tagName',
    'target',
    'teardownViews',
    'templateName',
    'testCheckboxClick',
    'testHelpers',
    'testing',
    'textarea',
    'then',
    'throttle',
    'title',
    'to',
    'toArray',
    'toString',
    'toggleProperty',
    'transitionTo',
    'transitionToRoute',
    'translateToContainerFullname',
    'trigger',
    'triggerAction',
    'triggerEvent',
    'tryInvoke',
    'trySet',
    'type',
    'typeInjection',
    'typeOf',
    'unbound',
    'underscore',
    'union',
    'uniq',
    'uniqBy',
    'unless',
    'unregister',
    'unregisterHelper',
    'unregisterWaiter',
    'unshiftObject',
    'unshiftObjects',
    'unsubscribe',
    'unwatch',
    'url',
    'urlFor',
    'useRouterNaming',
    'userAgent',
    'validationCache',
    'value',
    'visit',
    'volatile',
    'w',
    'wait',
    'waitForDOMReady',
    'warn',
    'watch',
    'watchModelTypes',
    'watchRecords',
    'willClearRender',
    'willDestroy',
    'willDestroyElement',
    'willInsertElement',
    'willRender',
    'willTransition',
    'willUpdate',
    'with',
    'without',
    'wrap',
    'wrapModelType',
    'wrapRecord',
    'yield',
  ],
};
<|endoftext|>


<commit_before>(function () {
	'use strict';

	const spawn = require ('child_process').spawn,
		path = require ('path'),
		helpers = require ('yeoman-test'),
		temp = require ('temp'),
		mongo = require ('mongodb'),
		db = mongo.Db,
		server = mongo.Server,
		testDir = 'oldschool_test',
		prompts = {
			cfgName: 'test-app',
			cfgDescription: 'test-description',
			cfgHomepage: 'test-homepage',
			cfgBugs: 'test-issues',
			cfgLicense: 'MIT',
			cfgContribName: 'test-name',
			cfgContribEmail: 'test-email',
			cfgContribUrl: 'test-url',
			cfgRepository: 'test-repository',
			cfgFramework: 'AngularJS'
		};

	function create () {
		return new Promise ((resolve, reject) => {
			console.info ('Creating test directory');
			temp.mkdir (testDir, (e, dir) => {
				if (e) {
					reject (e);
				} else {
					var dbname = path.basename (dir);

					console.info (`Test directory created: ${ dir }`);
					process.chdir (dir);

					console.info ('Generating app');
					helpers.run (path.join ( __dirname, '../../app')).withPrompts (prompts).inDir (dir).on ('end', () => {
						var p;

						console.info ('Running npm install');
						p = spawn ('npm', [ 'install' ]).on ('close', (code) => {
							if (code) {
								reject (`failed to install npm modules: ${ code }`, dbname);
							} else {
								console.info ('Running bower install');
								p = spawn ('bower', [ 'install' ]).on ('close', (code) => {
									if (code) {
										reject (`failed to install bower modules: ${ code }`, dbname);
									} else {
										console.info ('Running gulp ci');
										p = spawn ('gulp', [ 'ci', 'build' ]).on ('close', (code) => {
											if (code) {
												reject (`gulp failed: ${ code }`, dbname);
											} else {
												resolve (dbname);
											}
										});
										p.stdout.pipe (process.stdout);
										p.stderr.pipe (process.stderr);
									}
								});
								p.stdout.pipe (process.stdout);
								p.stderr.pipe (process.stderr);
							}
						});
						p.stdout.pipe (process.stdout);
						p.stderr.pipe (process.stderr);
					}).on ('error', (e) => {
						reject ('failed to generate: ' + e, dbname);
					});
				}
			});
		});
	}

	function dropDb (name) {
		if (name) {
			return new Promise ((resolve, reject)  => {
				new db (name, new server ('localhost', 27017)).open ().then ((d) => {
					d.dropDatabase ().then (() => {
						resolve ();
					}).catch ((err) => {
						reject (err);
					});
				}).catch ((err) => {
					reject (err);
				});
			});
		} else {
			return Promise.resolve ();
		}
	}

	temp.track ();

	create ().then ((dbname) => {
		dropDb (dbname).then (() => {
			process.exit (0);
		}).catch ((err) => {
			console.error (err);
			process.exit (1)
		});
	}).catch ((err, dbname) => {
		console.error (err);
		dropDb (dbname).then (() => {
			process.exit (1);
		}).catch ((err) => {
			console.error (err);
			process.exit (1)
		});
	});
} ());
<commit_msg>lint fix for #41<commit_after>(function () {
	'use strict';

	const spawn = require ('child_process').spawn,
		path = require ('path'),
		helpers = require ('yeoman-test'),
		temp = require ('temp'),
		mongo = require ('mongodb'),
		db = mongo.Db,
		server = mongo.Server,
		testDir = 'oldschool_test',
		prompts = {
			cfgName: 'test-app',
			cfgDescription: 'test-description',
			cfgHomepage: 'test-homepage',
			cfgBugs: 'test-issues',
			cfgLicense: 'MIT',
			cfgContribName: 'test-name',
			cfgContribEmail: 'test-email',
			cfgContribUrl: 'test-url',
			cfgRepository: 'test-repository',
			cfgFramework: 'AngularJS'
		};

	function create () {
		return new Promise ((resolve, reject) => {
			console.info ('Creating test directory');
			temp.mkdir (testDir, (e, dir) => {
				if (e) {
					reject (e);
				} else {
					var dbname = path.basename (dir);

					console.info (`Test directory created: ${ dir }`);
					process.chdir (dir);

					console.info ('Generating app');
					helpers.run (path.join ( __dirname, '../../app')).withPrompts (prompts).inDir (dir).on ('end', () => {
						var p;

						console.info ('Running npm install');
						p = spawn ('npm', [ 'install' ]).on ('close', (code) => {
							if (code) {
								reject (`failed to install npm modules: ${ code }`, dbname);
							} else {
								console.info ('Running bower install');
								p = spawn ('bower', [ 'install' ]).on ('close', (code) => {
									if (code) {
										reject (`failed to install bower modules: ${ code }`, dbname);
									} else {
										console.info ('Running gulp ci');
										p = spawn ('gulp', [ 'ci', 'build' ]).on ('close', (code) => {
											if (code) {
												reject (`gulp failed: ${ code }`, dbname);
											} else {
												resolve (dbname);
											}
										});
										p.stdout.pipe (process.stdout);
										p.stderr.pipe (process.stderr);
									}
								});
								p.stdout.pipe (process.stdout);
								p.stderr.pipe (process.stderr);
							}
						});
						p.stdout.pipe (process.stdout);
						p.stderr.pipe (process.stderr);
					}).on ('error', (e) => {
						reject ('failed to generate: ' + e, dbname);
					});
				}
			});
		});
	}

	function dropDb (name) {
		if (name) {
			return new Promise ((resolve, reject)  => {
				new db (name, new server ('localhost', 27017)).open ().then ((d) => {
					d.dropDatabase ().then (() => {
						resolve ();
					}).catch ((err) => {
						reject (err);
					});
				}).catch ((err) => {
					reject (err);
				});
			});
		} else {
			return Promise.resolve ();
		}
	}

	temp.track ();

	create ().then ((dbname) => {
		dropDb (dbname).then (() => {
			process.exit (0);
		}).catch ((err) => {
			console.error (err);
			process.exit (1);
		});
	}).catch ((err, dbname) => {
		console.error (err);
		dropDb (dbname).then (() => {
			process.exit (1);
		}).catch ((err) => {
			console.error (err);
			process.exit (1);
		});
	});
} ());
<|endoftext|>


<commit_before>module("Slide effect")

test('Should work', function() {

    var ct = Ember.AnimatedContainerView.create({
        name: 'foo',
        view: Ember.View.create({
            template: function() {
                return "Slide, and jump!";
            }
        })
    });

    Ember.run(function() {
        ct.appendTo('#qunit-fixture');
    });

    var view =

    Ember.run(function() {
        ct.set('currentView', view);
    });

    equal(Ember.$.trim(ct.$().text()), "Slide, and jump!");

    Ember.run(function(){
        ct.destroy();
    });

});<commit_msg>Removed unused test class<commit_after><|endoftext|>


<commit_before>

var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
var to_del = [];
// var options = {mechanisms: ['indexeddb']};
var options = {mechanisms: ['websql']};

var setUp = function() {

  ydn.json.POLY_FILL = true;
  // ydn.debug.log('ydn.db', 'finest');
  // ydn.db.crud.req.WebSql.DEBUG = true;
  // ydn.debug.log('ydn.db', 'finest');
  // ydn.db.tr.Serial.DEBUG = true;
  //ydn.db.crud.req.IndexedDb.DEBUG = true;
  // ydn.db.con.IndexedDb.DEBUG = true;

};

var tearDown = function() {
  var name;
  while (name = to_del.pop()) {
    ydn.db.deleteDatabase(name, options.mechanisms[0]);
  }
};

function test_compoundindex() {
  var db_name = 'test_issue_98';
  var db = new ydn.db.Storage('test_issue_98', {
    stores: [
      {
        name: 'test',
        keyPath: 'id',
        indexes: [
          {
            keyPath: ['first', 'last']
          },
          {
            keyPath: 'first'
          },
          {
            keyPath: 'last'
          }
        ]
      }]
  }, options);

  var data = [{id: 1, first: 'First', last: 'Last'}, {
    id: 2,
    first: 'First',
    last: 'Last'
  }];
  db.put('test', data[0]);
  db.put('test', data[1]);

  asyncTestCase.waitForAsync();
  db.from('test').where('first', '=', 'First').order('last').list(20).addCallbacks(function(x) {
    assertArrayEquals(data, x);
    asyncTestCase.continueTesting();
  }, function(e) {
    fail(e);
  });
  to_del.push(to_del);
}

<commit_msg>correct test<commit_after>

var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
var to_del = [];
// var options = {mechanisms: ['indexeddb']};
var options = {mechanisms: ['websql']};

var setUp = function() {

  ydn.json.POLY_FILL = true;
  ydn.debug.log('ydn.db', 'finest');

};

var tearDown = function() {
  var name;
  while (name = to_del.pop()) {
    ydn.db.deleteDatabase(name, options.mechanisms[0]);
  }
};

function test_compoundindex() {
  var db_name = 'test_issue_98';
  var schema = {
    stores: [
      {
        name: 'test',
        keyPath: 'id',
        indexes: [
          {
            keyPath: ['first', 'last'],
            name: 'first-last'
          },
          {
            keyPath: 'first'
          },
          {
            keyPath: 'last'
          }
        ]
      }]
  };
  var db = new ydn.db.Storage('test_issue_98', schema, options);

  var data = [{id: 1, first: 'First', last: 'Last'}, {
    id: 2,
    first: 'First',
    last: 'Last'
  }];
  db.put('test', data[0]);
  db.put('test', data[1]);

  asyncTestCase.waitForAsync('first');
  db.from('test').where('first', '=', 'First').order('last').list(20).addCallbacks(function(x) {
    assertArrayEquals(data, x);
    asyncTestCase.continueTesting();
    asyncTestCase.waitForAsync('second');
    db.close();
    var db2 = new ydn.db.Storage('test_issue_98', schema, options);
    db2.from('test').where('first', '=', 'First').order('last').list(20).addCallbacks(function(x) {
      assertArrayEquals(data, x);
      asyncTestCase.continueTesting();
      db2.close();
    }, function(e) {
      fail(e);
    });
  }, function(e) {
    fail(e);
  });
  to_del.push(to_del);
}

<|endoftext|>


<commit_before>
var range = itertools.range ;
var by = itertools.by ;
var zip = itertools.zip ;
var list = itertools.list ;

test( "by" , function ( ) {

	var A = by( range( 100 ) , 2 ) ;
	var B = zip( [ range( 0 , 100 , 2 ) , range( 1 , 100 , 2 ) ] ) ;

	deepEqual( list( A ) , list( B ) , "compare to zip output" ) ;

	var A = by( range( 4 ) , 3 ) ;

	deepEqual( list( A ) , [ [ 0 , 1 , 2 ] , [ 3 , undefined , undefined ] ] , "n !| N" ) ;

} ) ;

<commit_msg>fixes<commit_after>
var range = itertools.range ;
var by = itertools.by ;
var zip = itertools.zip ;
var list = itertools.list ;

test( "by" , function ( ) {

	var A = by( range( 100 ) , 2 ) ;
	var B = zip( [ range( 0 , 100 , 2 ) , range( 1 , 100 , 2 ) ] ) ;

	deepEqual( list( A ) , list( B ) , "compare to zip output" ) ;

	var C = by( range( 4 ) , 3 ) ;

	deepEqual( list( C ) , [ [ 0 , 1 , 2 ] , [ 3 , undefined , undefined ] ] , "n !| N" ) ;

	var D = by( "" , 3 ) ;

	deepEqual( list( D ) , [ ] , "empty" ) ;

} ) ;

<|endoftext|>


<commit_before>/*
* @Author: Mike Reich
* @Date:   2015-07-16 07:40:46
* @Last Modified 2016-09-06
*/

'use strict';

import {Application} from '../../lib'

import Promise from 'bluebird'

describe("Application", () => {
  var app;
  describe("Load", () => {
    it("should not be null", () => Application.should.not.be.null())

    it("should be instantiated", () => (app = new Application()).should.not.be.null())

    it("should have the logger", () => app.log.should.not.be.null())

    it("should use the passed in appDir if present", () => {
      app = new Application({appDir: 'someValue'})
      app.config.appDir.should.eql('someValue')
    })

    it("should have the default config vars", () => {
      app = new Application()
      app.should.have.property('config')
      app.config.should.have.property('baseUrl')
      app.config.should.have.property('siteName')
    })
  })

  describe("Events", () => {
    beforeEach(() => {
      app = new Application({silent: true})
    })

    it("should bind to events", () => {
      app.on.should.not.be.null()
      app.once.should.not.be.null()
    })

    it("should dispatch events", (done) => {
      app.once('test').then(done)
      app.emit('test')
    })
    it("once is thenable", (done) => {
      app.once('test').then(done)
      app.emit('test')
    })
    it("on takes a handler", (done) => {
      app.on('test', done);
      app.emit('test')
    })
    it("once takes a handler", (done) => {
      app.once('test', done);
      app.emit('test')
    })
    it("should dispatch events multiple times", (done) => {
      var count = 0;
      app.on('test', function(arg) {
        count++;
        if(count == 1) {
          arg.should.equal(1)
        }
        if(count >= 2) {
          arg.should.equal(2)
          done()
        }
      })
      app.emit('test', 1)
      app.emit('test', 2)
    })
    it("once should wait for events that return a promise", (done) => {
      var waited = false;
      app.once('launch').then(() => {
        waited.should.be.true();
        done();
      });
      var promise = new Promise((resolve, reject) => {
        setTimeout(() => { waited = true; resolve(); }, 500);
      });
      app.once('init', () => { return promise });
      app.start();

    });
    it("on should wait for events that return a promise", (done) => {
      var waited = false;
      app.once('launch').then(() => {
        waited.should.be.true();
        done();
      });
      var promise = new Promise((resolve, reject) => {
        setTimeout(() => { waited = true; resolve(); }, 500);
      });
      app.on('init', () => { return promise });
      app.start();

    });
    it("before > handlers > after", (done) => {
      var waited = false;
      app.before('init', () => {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            waited.should.be.false();
            resolve();
          }, 500);
        })
      });
      app.after('init', () => {
        waited.should.be.true();
        done();
      });

      app.on('init', () => {
        return new Promise((resolve, reject) => {
          setTimeout(() => { waited = true; resolve(); }, 200);
        });
      });
      app.start();

    });
    it("before modifies args", (done) => {
      app.before('tester', (args) => {
        args[0].should.equal(1);
        return new Promise((resolve, reject) => {
          resolve([2]);
        });
      });
      app.on('tester', (i) => {
        i.should.equal(2)
        done();
      });
      app.emit('tester', 1)

    });
    it("after modifies results", (done) => {
      app.after('tester', (results) => {
        results.should.equal("test");
        return new Promise((resolve, reject) => {
          resolve("best");
        });
      });
      app.on('tester', (i) => {
        return "test"
      });
      app.emit('tester', 1).then((result) => {
        result.should.equal("best");
        done();
      })
    });

    it("after modifies multiple results", (done) => {
      app.after('tester', (results) => {
        results.should.equal("test");
        return new Promise((resolve, reject) => {
          resolve("best");
        });
      });
      app.after('tester', (results) => {
        results.should.equal("best");
        return new Promise((resolve, reject) => {
          resolve(["best", "nest"]);
        });
      });
      app.on('tester', (i) => {
        return "test"
      });
      app.emit('tester', 1).then(([result1, result2]) => {
        result1.should.equal("best");
        result2.should.equal("nest");
        done();
      })
    });
  })

  describe("Boot Stages", () => {
    beforeEach(() => {
      app = new Application({silent: true})
    })

    it("should send the init event", (done) => {
      app.once('init').then(done)
      app.start()
    })

    it("should send the load event", (done) => {
      app.once('load').then(done)
      app.start()
    })

    it("should send the startup event", (done) => {
      app.once('startup').then(done)
      app.start()
    })

    it("should send the launch event", (done) => {
      app.once('launch').then(done)
      app.start()
    })
  })

  describe("Get Module", () => {
    beforeEach(() => {
      app = new Application()
    })

    it("should return a Module", (done) => {
      app.get('something').on.should.be.Function()
      app.get('something').gather.should.be.Function()
      app.get('something').provide.should.be.Function()
      done();
    });
  });
})
<commit_msg>tests<commit_after>/*
* @Author: Mike Reich
* @Date:   2015-07-16 07:40:46
* @Last Modified 2016-09-06
*/

'use strict';

import {Application} from '../../lib'

import Promise from 'bluebird'

describe("Application", () => {
  var app;
  describe("Load", () => {
    it("should not be null", () => Application.should.not.be.null())

    it("should be instantiated", () => (app = new Application()).should.not.be.null())

    it("should have the logger", () => app.log.should.not.be.null())
  })

  describe("Events", () => {
    beforeEach(() => {
      app = new Application({silent: true})
    })

    it("should bind to events", () => {
      app.on.should.not.be.null()
      app.once.should.not.be.null()
    })

    it("should dispatch events", (done) => {
      app.once('test').then(done)
      app.emit('test')
    })
    it("once is thenable", (done) => {
      app.once('test').then(done)
      app.emit('test')
    })
    it("on takes a handler", (done) => {
      app.on('test', done);
      app.emit('test')
    })
    it("once takes a handler", (done) => {
      app.once('test', done);
      app.emit('test')
    })
    it("should dispatch events multiple times", (done) => {
      var count = 0;
      app.on('test', function(arg) {
        count++;
        if(count == 1) {
          arg.should.equal(1)
        }
        if(count >= 2) {
          arg.should.equal(2)
          done()
        }
      })
      app.emit('test', 1)
      app.emit('test', 2)
    })
    it("once should wait for events that return a promise", (done) => {
      var waited = false;
      app.once('launch').then(() => {
        waited.should.be.true();
        done();
      });
      var promise = new Promise((resolve, reject) => {
        setTimeout(() => { waited = true; resolve(); }, 500);
      });
      app.once('init', () => { return promise });
      app.start();

    });
    it("on should wait for events that return a promise", (done) => {
      var waited = false;
      app.once('launch').then(() => {
        waited.should.be.true();
        done();
      });
      var promise = new Promise((resolve, reject) => {
        setTimeout(() => { waited = true; resolve(); }, 500);
      });
      app.on('init', () => { return promise });
      app.start();

    });
    it("before > handlers > after", (done) => {
      var waited = false;
      app.before('init', () => {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            waited.should.be.false();
            resolve();
          }, 500);
        })
      });
      app.after('init', () => {
        waited.should.be.true();
        done();
      });

      app.on('init', () => {
        return new Promise((resolve, reject) => {
          setTimeout(() => { waited = true; resolve(); }, 200);
        });
      });
      app.start();

    });
    it("before modifies args", (done) => {
      app.before('tester', (args) => {
        args[0].should.equal(1);
        return new Promise((resolve, reject) => {
          resolve([2]);
        });
      });
      app.on('tester', (i) => {
        i.should.equal(2)
        done();
      });
      app.emit('tester', 1)

    });
    it("after modifies results", (done) => {
      app.after('tester', (results) => {
        results.should.equal("test");
        return new Promise((resolve, reject) => {
          resolve("best");
        });
      });
      app.on('tester', (i) => {
        return "test"
      });
      app.emit('tester', 1).then((result) => {
        result.should.equal("best");
        done();
      })
    });

    it("after modifies multiple results", (done) => {
      app.after('tester', (results) => {
        results.should.equal("test");
        return new Promise((resolve, reject) => {
          resolve("best");
        });
      });
      app.after('tester', (results) => {
        results.should.equal("best");
        return new Promise((resolve, reject) => {
          resolve(["best", "nest"]);
        });
      });
      app.on('tester', (i) => {
        return "test"
      });
      app.emit('tester', 1).then(([result1, result2]) => {
        result1.should.equal("best");
        result2.should.equal("nest");
        done();
      })
    });
  })

  describe("Config on startup", () => {
    it("should use the passed in appDir if present", (done) => {
      app = new Application({appDir: 'someValue'})
      app.on('init', () => {
        app.config.appDir.should.eql('someValue')
        done()
      })
      app.start()
    })

    it("should have the default config vars", (done) => {
      app = new Application()
      app.on('init', () => {
        app.should.have.property('config')
        app.config.should.have.property('baseUrl')
        app.config.should.have.property('siteName')
        done()
      })
      app.start()
    })
  })

  describe("Boot Stages", () => {
    beforeEach(() => {
      app = new Application({silent: true})
    })

    it("should send the init event", (done) => {
      app.once('init').then(done)
      app.start()
    })

    it("should send the load event", (done) => {
      app.once('load').then(done)
      app.start()
    })

    it("should send the startup event", (done) => {
      app.once('startup').then(done)
      app.start()
    })

    it("should send the launch event", (done) => {
      app.once('launch').then(done)
      app.start()
    })
  })

  describe("Get Module", () => {
    beforeEach(() => {
      app = new Application()
    })

    it("should return a Module", (done) => {
      app.get('something').on.should.be.Function()
      app.get('something').gather.should.be.Function()
      app.get('something').provide.should.be.Function()
      done();
    });
  });
})
<|endoftext|>


<commit_before>/**
 * Copyright (c) 2013-2018 Memba Sarl. All rights reserved.
 * Sources at https://github.com/Memba
 */

/* jshint node: true */

'use strict';

var assert = require('assert');
var chalk = require('chalk');
var config = require('../config');

var RX_LEVELS = /^(debug|info|warn|error|crit)$/i;
var levels = {
        debug: 1,
        info: 2,
        warn: 4,
        error: 5,
        crit: 6
    };
var eq = ': ';
var qt = '';
var prefix = ' ';
var separator = '; ';

chalk.debug = chalk.gray;
chalk.info = chalk.green;
chalk.warn = chalk.yellow;
chalk.error = chalk.magenta;
chalk.crit = chalk.red;

/* This function has too many statements. */
/* jshint -W071 */

/* This function's cyclomatic complexity is too high. */
/* jshint -W074 */

/**
 * Format log entry with request data
 * @param entry
 * @param level
 * @returns {*}
 */
function format(entry, level) {
    assert.ok(typeof entry === 'object', '`entry` is expected to be an object');
    assert.ok(RX_LEVELS.test(level), '`level` is expected to be any of `debug`, `info`, `warn`, `error` or `crit`');
    // JSON.stringify(new Error('Oops)) === {} and we do not want to clutter our logs with 'undefined'
    // So we need to capture the properties we want after testing that they exist
    var ret = {};
    // Message
    if (entry.message) {
        ret.message = entry.message;
    } else if (entry.error instanceof Error) {
        ret.message = entry.error.message;
    }
    // Level
    ret.level = level.toLowerCase();
    // Application
    var application = config.get('application:name');
    if (application) {
        ret.application = application;
    }
    if (entry.module) {
        ret.module = entry.module;
    }
    if (entry.method) {
        ret.method = entry.method;
    }
    // Host
    if (process.env.HOSTNAME) {
        ret.host = process.env.HOSTNAME;
    }
    var request = entry.request;
    // IP Address
    if (request && request.ip) {
        ret.ip = request.ip;
    }
    // User Agent
    if (request && request.header && request.headers['user-agent']) {
        ret.agent = request.headers['user-agent'];
    }
    // Scheme
    if (entry.scheme) {
        ret.scheme = entry.scheme;
    } else if (request && request.scheme) {
        ret.scheme = request.scheme;
    }
    // Trace
    if (entry.trace) {
        ret.trace = entry.trace;
    } else if (request && request.trace) {
        ret.trace = request.trace;
    }
    // Url
    if (entry.url) {
        ret.url = entry.url;
    } else if (request && request.url) {
        ret.url = request.url;
    }
    // Query
    if (entry.query) {
        ret.query = entry.query;
    } else if (request && request.query) {
        ret.query = request.query;
    }
    // Error message and stack
    if (entry.stack) {
        if (entry.message) {
            ret.error = entry.message;
        }
        ret.stack = entry.stack;
    } else if (entry.error && entry.error.stack) {
        if (entry.error.message) {
            ret.error = entry.error.message;
        } else if (entry.error.originalError && entry.error.originalError.message) {
            // entry.error.originalError is not necessarily an instance of Error because we use deepExtend
            // TODO: CHeck that this actually occurs
            ret.error = entry.error.originalError.message;
        }
        ret.stack = entry.error.stack;
    }
    // entry.date = (new Date()).toISOString();
    // Note: such an entry is not only ready to print to console but also to be sent as JSON
    return ret;
}

/**
* Print a log entry to the console
* Note: we have discarded coloured solutions because they do not print well in Webstorm console
* @param entry
*/
function print(entry) {
    /* jshint maxstatements: 52 */
    /* jshint maxcomplexity: 39 */
    var message = (isNaN(Date.parse(entry.date)) ? new Date() : new Date(entry.date)).toISOString();
    message += prefix + '[' + entry.level.toUpperCase() + ']' + (entry.level.length > 4 ? '' : ' ');
    var first = true;
    if (entry.application) {
        message += (first ? prefix : separator) + 'application' + eq + qt + entry.application + qt;
        first = false;
    }
    if (entry.host) {
        message += (first ? prefix : separator) + 'host' + eq + qt + entry.host + qt;
        first = false;
    }
    if (entry.message) {
        message += (first ? prefix : separator) + 'message' + eq + qt + entry.message + qt;
        first = false;
    }
    if (entry.originalMessage) {
        message += (first ? prefix : separator) + 'originalMessage' + eq + qt + entry.originalMessage + qt;
        first = false;
    }
    if (entry.module) {
        message += (first ? prefix : separator) + 'module' + eq + qt + entry.module + qt;
        first = false;
    }
    if (entry.method) {
        message += (first ? prefix : separator) + 'method' + eq + qt + entry.method + qt;
        first = false;
    }
    if (entry.data) {
        try {
            message += (first ? prefix : separator) + 'data' + eq + qt + JSON.stringify(entry.data) + qt;
        } catch (ex) {
            if (typeof entry.data.toString === 'function') {
                message += (first ? prefix : separator) + 'data' + eq + qt + entry.data.toString() + qt;
            }
        }
        first = false;
    }
    if (entry.url) {
        message += (first ? prefix : separator) + 'url' + eq + qt + entry.url + qt;
        first = false;
    }
    if (entry.query) {
        try {
            message += (first ? prefix : separator) + 'query' + eq + qt + JSON.stringify(entry.query) + qt;
        } catch (ex) {
            if (typeof entry.data.toString === 'function') {
                message += (first ? prefix : separator) + 'query' + eq + qt + entry.query.toString() + qt;
            }
        }
        first = false;
    }
    if (entry.scheme) {
        message += (first ? prefix : separator) + 'scheme' + eq + qt + entry.scheme + qt;
        first = false;
    }
    if (entry.trace) {
        message += (first ? prefix : separator) + 'trace' + eq + qt + entry.trace + qt;
        first = false;
    }
    if (entry.ip) {
        message += (first ? prefix : separator) + 'ip' + eq + qt + entry.ip + qt;
        first = false;
    }
    if (entry.agent) {
        message += (first ? prefix : separator) + 'agent' + eq + qt + entry.agent + qt;
        first = false;
    }
    if (entry.stack) {
        message += (first ? prefix : separator) + 'stack' + eq + qt + entry.stack.split('\n').join(', ').replace(/\s+/g, ' ') + qt;
    }
    console.log(chalk.supportsColor ? chalk[entry.level || 'debug'](message) : message);
    return message;
}

/* jshint +W074 */
/* jshint +W071 */

module.exports = exports = {

    /**
     * Log a debug entry
     * Only output if debug===true
     * @param entry
     */
    debug: function (entry) {
        // Note: config.get('level') cannot be cached in a module variable because it is not available when the module loads when loading production.json from AWS S3
        if ((config.get('level') || 0) > levels.debug) {
            return false;
        }
        print(format(entry, 'debug'));
        return true;
    },

    /**
     * Log an info entry
     * @param entry
     */
    info: function (entry) {
        if ((config.get('level') || 0) > levels.info) {
            return false;
        }
        print(format(entry, 'info'));
        return true;
    },

    /**
     * Log a warning entry
     * @param entry
     */
    warn: function (entry) {
        if ((config.get('level') || 0) > levels.warn) {
            return false;
        }
        print(format(entry, 'warn'));
        return true;
    },

    /**
     * Log an error entry
     * @param entry
     */
    error: function (entry) {
        if ((config.get('level') || 0) > levels.error) {
            return false;
        }
        print(format(entry, 'error'));
        return true;
    },

    /**
     * Log a critical entry
     * @param entry
     */
    critical: function (entry) {
        if ((config.get('level') || 0) > levels.crit) {
            return false;
        }
        var plugins = require('../plugins');
        var formatted = format(entry, 'crit');
        print(formatted);
        plugins.emit('slack', {
            slack: {
                channel: config.get('slack:channels:weberrors'),
                level: formatted.level,
                text: formatted.message
            },
            model: formatted
        });
        return true;
    },

    /**
     * Shortcut for critical
     */
    crit: function (entry) {
        exports.critical(entry);
    }

};
<commit_msg>Added data to logger<commit_after>/**
 * Copyright (c) 2013-2018 Memba Sarl. All rights reserved.
 * Sources at https://github.com/Memba
 */

/* jshint node: true */

'use strict';

var assert = require('assert');
var chalk = require('chalk');
var config = require('../config');

var RX_LEVELS = /^(debug|info|warn|error|crit)$/i;
var levels = {
        debug: 1,
        info: 2,
        warn: 4,
        error: 5,
        crit: 6
    };
var eq = ': ';
var qt = '';
var prefix = ' ';
var separator = '; ';

chalk.debug = chalk.gray;
chalk.info = chalk.green;
chalk.warn = chalk.yellow;
chalk.error = chalk.magenta;
chalk.crit = chalk.red;

/* This function has too many statements. */
/* jshint -W071 */

/* This function's cyclomatic complexity is too high. */
/* jshint -W074 */

/**
 * Format log entry with request data
 * @param entry
 * @param level
 * @returns {*}
 */
function format(entry, level) {
    assert.ok(typeof entry === 'object', '`entry` is expected to be an object');
    assert.ok(RX_LEVELS.test(level), '`level` is expected to be any of `debug`, `info`, `warn`, `error` or `crit`');
    // JSON.stringify(new Error('Oops)) === {} and we do not want to clutter our logs with 'undefined'
    // So we need to capture the properties we want after testing that they exist
    var ret = {};
    // Message
    if (entry.message) {
        ret.message = entry.message;
    } else if (entry.error instanceof Error) {
        ret.message = entry.error.message;
    }
    // Level
    ret.level = level.toLowerCase();
    // Application
    var application = config.get('application:name');
    if (application) {
        ret.application = application;
    }
    if (entry.module) {
        ret.module = entry.module;
    }
    if (entry.method) {
        ret.method = entry.method;
    }
    // Host
    if (process.env.HOSTNAME) {
        ret.host = process.env.HOSTNAME;
    }
    var request = entry.request;
    // IP Address
    if (request && request.ip) {
        ret.ip = request.ip;
    }
    // User Agent
    if (request && request.header && request.headers['user-agent']) {
        ret.agent = request.headers['user-agent'];
    }
    // Scheme
    if (entry.scheme) {
        ret.scheme = entry.scheme;
    } else if (request && request.scheme) {
        ret.scheme = request.scheme;
    }
    // Trace
    if (entry.trace) {
        ret.trace = entry.trace;
    } else if (request && request.trace) {
        ret.trace = request.trace;
    }
    // Url
    if (entry.url) {
        ret.url = entry.url;
    } else if (request && request.url) {
        ret.url = request.url;
    }
    // Query
    if (entry.query) {
        ret.query = entry.query;
    } else if (request && request.query) {
        ret.query = request.query;
    }
    // Data
    if (entry.data) {
        ret.data = entry.data;
    }
    // Error message and stack
    if (entry.stack) {
        if (entry.message) {
            ret.error = entry.message;
        }
        ret.stack = entry.stack;
    } else if (entry.error && entry.error.stack) {
        if (entry.error.message) {
            ret.error = entry.error.message;
        } else if (entry.error.originalError && entry.error.originalError.message) {
            // entry.error.originalError is not necessarily an instance of Error because we use deepExtend
            // TODO: CHeck that this actually occurs
            ret.error = entry.error.originalError.message;
        }
        ret.stack = entry.error.stack;
    }
    // entry.date = (new Date()).toISOString();
    // Note: such an entry is not only ready to print to console but also to be sent as JSON
    return ret;
}

/**
* Print a log entry to the console
* Note: we have discarded coloured solutions because they do not print well in Webstorm console
* @param entry
*/
function print(entry) {
    /* jshint maxstatements: 52 */
    /* jshint maxcomplexity: 39 */
    var message = (isNaN(Date.parse(entry.date)) ? new Date() : new Date(entry.date)).toISOString();
    message += prefix + '[' + entry.level.toUpperCase() + ']' + (entry.level.length > 4 ? '' : ' ');
    var first = true;
    if (entry.application) {
        message += (first ? prefix : separator) + 'application' + eq + qt + entry.application + qt;
        first = false;
    }
    if (entry.host) {
        message += (first ? prefix : separator) + 'host' + eq + qt + entry.host + qt;
        first = false;
    }
    if (entry.message) {
        message += (first ? prefix : separator) + 'message' + eq + qt + entry.message + qt;
        first = false;
    }
    if (entry.originalMessage) {
        message += (first ? prefix : separator) + 'originalMessage' + eq + qt + entry.originalMessage + qt;
        first = false;
    }
    if (entry.module) {
        message += (first ? prefix : separator) + 'module' + eq + qt + entry.module + qt;
        first = false;
    }
    if (entry.method) {
        message += (first ? prefix : separator) + 'method' + eq + qt + entry.method + qt;
        first = false;
    }
    if (entry.data) {
        try {
            message += (first ? prefix : separator) + 'data' + eq + qt + JSON.stringify(entry.data) + qt;
        } catch (ex) {
            if (typeof entry.data.toString === 'function') {
                message += (first ? prefix : separator) + 'data' + eq + qt + entry.data.toString() + qt;
            }
        }
        first = false;
    }
    if (entry.url) {
        message += (first ? prefix : separator) + 'url' + eq + qt + entry.url + qt;
        first = false;
    }
    if (entry.query) {
        try {
            message += (first ? prefix : separator) + 'query' + eq + qt + JSON.stringify(entry.query) + qt;
        } catch (ex) {
            if (typeof entry.query.toString === 'function') {
                message += (first ? prefix : separator) + 'query' + eq + qt + entry.query.toString() + qt;
            }
        }
        first = false;
    }
    if (entry.scheme) {
        message += (first ? prefix : separator) + 'scheme' + eq + qt + entry.scheme + qt;
        first = false;
    }
    if (entry.trace) {
        message += (first ? prefix : separator) + 'trace' + eq + qt + entry.trace + qt;
        first = false;
    }
    if (entry.ip) {
        message += (first ? prefix : separator) + 'ip' + eq + qt + entry.ip + qt;
        first = false;
    }
    if (entry.agent) {
        message += (first ? prefix : separator) + 'agent' + eq + qt + entry.agent + qt;
        first = false;
    }
    if (entry.stack) {
        message += (first ? prefix : separator) + 'stack' + eq + qt + entry.stack.split('\n').join(', ').replace(/\s+/g, ' ') + qt;
    }
    console.log(chalk.supportsColor ? chalk[entry.level || 'debug'](message) : message);
    return message;
}

/* jshint +W074 */
/* jshint +W071 */

module.exports = exports = {

    /**
     * Log a debug entry
     * Only output if debug===true
     * @param entry
     */
    debug: function (entry) {
        // Note: config.get('level') cannot be cached in a module variable because it is not available when the module loads when loading production.json from AWS S3
        if ((config.get('level') || 0) > levels.debug) {
            return false;
        }
        print(format(entry, 'debug'));
        return true;
    },

    /**
     * Log an info entry
     * @param entry
     */
    info: function (entry) {
        if ((config.get('level') || 0) > levels.info) {
            return false;
        }
        print(format(entry, 'info'));
        return true;
    },

    /**
     * Log a warning entry
     * @param entry
     */
    warn: function (entry) {
        if ((config.get('level') || 0) > levels.warn) {
            return false;
        }
        print(format(entry, 'warn'));
        return true;
    },

    /**
     * Log an error entry
     * @param entry
     */
    error: function (entry) {
        if ((config.get('level') || 0) > levels.error) {
            return false;
        }
        print(format(entry, 'error'));
        return true;
    },

    /**
     * Log a critical entry
     * @param entry
     */
    critical: function (entry) {
        if ((config.get('level') || 0) > levels.crit) {
            return false;
        }
        var plugins = require('../plugins');
        var formatted = format(entry, 'crit');
        print(formatted);
        plugins.emit('slack', {
            slack: {
                channel: config.get('slack:channels:weberrors'),
                level: formatted.level,
                text: formatted.message
            },
            model: formatted
        });
        return true;
    },

    /**
     * Shortcut for critical
     */
    crit: function (entry) {
        exports.critical(entry);
    }

};
<|endoftext|>


<commit_before>import { expect } from 'chai';

import Group from '../../src/model/Group';
import Action from '../../src/model/Action';

describe('model/Group', () => {

  const name = 'foo';
  const type = 'bar';
  const config = {
    i: { p1: { type: 'int' }, p2: { type: 'string' } },
    o: { q1: { type: 'file' }, q2: { type: 'string' } },
  };

  describe('constructor', () => {

    it('requires a name', () => {
      expect(() => new Group()).to.throw(Error);
      expect(() => new Group(name)).to.not.throw(Error);
      expect(new Group(name).name).to.equal(name);
    });

    it('allows empty configuration', () => {
      const group = new Group(name);
      expect(group).to.contain.all.keys(['name', 'i', 'o', 'action', 'children', 'parent']);
      expect(group.i).to.be.empty;
      expect(group.o).to.be.empty;
      expect(group.action).to.be.an.instanceOf(Action, 'group.action');
      expect(group.children).to.be.empty;
      expect(group.parent).to.be.null;
    });

    it('requires a type', () => {
      expect(() => new Group()).to.throw(Error);
      expect(() => new Group(name, type)).to.not.throw(Error);
      expect(new Group(name, type).type).to.equal(type);
    });

    it('throws error when try to create with ports', () => {
      expect(() => new Group(name, type, config)).to.not.throw(Error);
    });

    it('throws error when try to create with action', () => {
      expect(() => new Group(name, type, new Action(name, config))).to.throw(Error);
    });
  });
});
<commit_msg>Renamed test<commit_after>import { expect } from 'chai';

import Group from '../../src/model/Group';
import Action from '../../src/model/Action';

describe('model/Group', () => {

  const name = 'foo';
  const type = 'bar';
  const config = {
    i: { p1: { type: 'int' }, p2: { type: 'string' } },
    o: { q1: { type: 'file' }, q2: { type: 'string' } },
  };

  describe('constructor', () => {

    it('requires a name', () => {
      expect(() => new Group()).to.throw(Error);
      expect(() => new Group(name)).to.not.throw(Error);
      expect(new Group(name).name).to.equal(name);
    });

    it('allows empty configuration', () => {
      const group = new Group(name);
      expect(group).to.contain.all.keys(['name', 'i', 'o', 'action', 'children', 'parent']);
      expect(group.i).to.be.empty;
      expect(group.o).to.be.empty;
      expect(group.action).to.be.an.instanceOf(Action, 'group.action');
      expect(group.children).to.be.empty;
      expect(group.parent).to.be.null;
    });

    it('requires a type', () => {
      expect(() => new Group()).to.throw(Error);
      expect(() => new Group(name, type)).to.not.throw(Error);
      expect(new Group(name, type).type).to.equal(type);
    });

    it('allows to create with ports', () => {
      expect(() => new Group(name, type, config)).to.not.throw(Error);
    });

    it('throws error when try to create with action', () => {
      expect(() => new Group(name, type, new Action(name, config))).to.throw(Error);
    });
  });
});
<|endoftext|>


<commit_before>/* jshint node: true */
'use strict';

module.exports = function(grunt) {
  require('load-grunt-tasks')(grunt);

  var pkg = require('./package.json');

  var config = pkg.gruntConfig || {};

  config.grunt = grunt;
  config.pkg = pkg;

  grunt.initConfig({
    // the default value should be the "dev" destination
    // this is not exactly the best solution, but otherwise, when tasks are "rerunned"
    // with the watch tasks, the value get lost...
    // so, it's fine for the "dist" build mode
    // who will override the value but only run once
    buildTarget:      config.devTarget,

    pkg:              pkg,

    bower:            require('camunda-commons-ui/grunt/config/bower')(config),

    jasmine_node:     require('camunda-commons-ui/grunt/config/jasmine_node')(config),

    karma:            require('camunda-commons-ui/grunt/config/karma')(config),

    protractor:       require('camunda-commons-ui/grunt/config/protractor')(config),

    seleniuminstall:  require('camunda-commons-ui/grunt/config/seleniuminstall')(config),

    requirejs:        require('./grunt/config/requirejs')(config),

    less:             require('camunda-commons-ui/grunt/config/less')(config),

    copy:             require('./grunt/config/copy')(config),

    watch:            require('./grunt/config/watch')(config),

    connect:          require('camunda-commons-ui/grunt/config/connect')(config),

    jsdoc:            require('camunda-commons-ui/grunt/config/jsdoc')(config),

    jshint:           require('camunda-commons-ui/grunt/config/jshint')(config),

    changelog:        require('camunda-commons-ui/grunt/config/changelog')(config),

    localescompile:   require('camunda-commons-ui/grunt/config/localescompile')(config),

    clean:            require('camunda-commons-ui/grunt/config/clean')(config)
  });

  require('camunda-commons-ui/grunt/tasks/localescompile')(grunt);

  grunt.registerTask('build', function(mode) {
    mode = mode || 'prod';

    grunt.config.data.buildTarget = (mode === 'prod' ? config.prodTarget : config.devTarget);
    grunt.log.subhead('Will build the "'+ pkg.name +'" project in "'+ mode +'" mode and place it in "'+ grunt.config('buildTarget') +'"');
    if (mode === 'dev') {
      grunt.log.writeln('Will serve on port "'+
        config.connectPort +
        '" and liverreload available on port "'+
        config.livereloadPort +
        '"');
    }

    var tasks = [
      'clean',
      'jshint',
      'jsdoc',
      'bower',
      'copy',
      'less',
      'localescompile',
      'requirejs'
    ];

    grunt.task.run(tasks);
  });

  grunt.registerTask('auto-build', [
    'build:dev',
    'connect',
    'watch'
  ]);

  grunt.registerTask('postinstall', ['seleniuminstall']);

  grunt.registerTask('prepublish', ['build', 'changelog']);

  grunt.registerTask('default', ['build']);
};
<commit_msg>fix(grunt): comment the seleniuminstall task<commit_after>/* jshint node: true */
'use strict';

module.exports = function(grunt) {
  require('load-grunt-tasks')(grunt);

  var pkg = require('./package.json');

  var config = pkg.gruntConfig || {};

  config.grunt = grunt;
  config.pkg = pkg;

  grunt.initConfig({
    // the default value should be the "dev" destination
    // this is not exactly the best solution, but otherwise, when tasks are "rerunned"
    // with the watch tasks, the value get lost...
    // so, it's fine for the "dist" build mode
    // who will override the value but only run once
    buildTarget:      config.devTarget,

    pkg:              pkg,

    bower:            require('camunda-commons-ui/grunt/config/bower')(config),

    jasmine_node:     require('camunda-commons-ui/grunt/config/jasmine_node')(config),

    karma:            require('camunda-commons-ui/grunt/config/karma')(config),

    protractor:       require('camunda-commons-ui/grunt/config/protractor')(config),

    // seleniuminstall:  require('camunda-commons-ui/grunt/config/seleniuminstall')(config),

    requirejs:        require('./grunt/config/requirejs')(config),

    less:             require('camunda-commons-ui/grunt/config/less')(config),

    copy:             require('./grunt/config/copy')(config),

    watch:            require('./grunt/config/watch')(config),

    connect:          require('camunda-commons-ui/grunt/config/connect')(config),

    jsdoc:            require('camunda-commons-ui/grunt/config/jsdoc')(config),

    jshint:           require('camunda-commons-ui/grunt/config/jshint')(config),

    changelog:        require('camunda-commons-ui/grunt/config/changelog')(config),

    localescompile:   require('camunda-commons-ui/grunt/config/localescompile')(config),

    clean:            require('camunda-commons-ui/grunt/config/clean')(config)
  });

  require('camunda-commons-ui/grunt/tasks/localescompile')(grunt);

  grunt.registerTask('build', function(mode) {
    mode = mode || 'prod';

    grunt.config.data.buildTarget = (mode === 'prod' ? config.prodTarget : config.devTarget);
    grunt.log.subhead('Will build the "'+ pkg.name +'" project in "'+ mode +'" mode and place it in "'+ grunt.config('buildTarget') +'"');
    if (mode === 'dev') {
      grunt.log.writeln('Will serve on port "'+
        config.connectPort +
        '" and liverreload available on port "'+
        config.livereloadPort +
        '"');
    }

    var tasks = [
      'clean',
      'jshint',
      'jsdoc',
      'bower',
      'copy',
      'less',
      'localescompile',
      'requirejs'
    ];

    grunt.task.run(tasks);
  });

  grunt.registerTask('auto-build', [
    'build:dev',
    'connect',
    'watch'
  ]);

  grunt.registerTask('postinstall', ['seleniuminstall']);

  grunt.registerTask('prepublish', ['build', 'changelog']);

  grunt.registerTask('default', ['build']);
};
<|endoftext|>


<commit_before>describe("SmartStorage", function() {

    var a, b;

    beforeEach(function() {
        // Kill any previous, and create two new storage objects.
        window.localStorage.clear();
        a = new SmartStorage("testdb1");
        b = new SmartStorage("testdb2");
        a.set("val1", "testval1");
        b.set("val1", "testval2");
    });

    it("should create two distinct storage objects", function() {
        expect(a.get("val1")).toEqual("testval1");
        expect(b.get("val1")).toEqual("testval2");
    });

    it("should store and return true/false values", function() {
        a.set("my_true", true);
        a.set("my_false", false);
        expect(a.get("my_true")).toBeTruthy();
        expect(a.get("my_false")).toBeFalsy();
    });

    it("should store and return string values", function() {
        a.set("val1", "testval1");
        a.set("val2", (new String("testval2")));
        expect(a.get("val1")).toEqual("testval1");
        expect(a.get("val2")).toEqual("testval2");
    });

    it("should store and return arrays", function() {
        my_array = [1,2,3,4,5];
        a.set("my_array", my_array);
        expect(a.get("my_array")[3]).toEqual(my_array[3]);
    });

    it("should store and return object/hash types", function() {
        my_object = {
            "key1": "value1",
            "key2": "value2",
            "key3": [1,2,3,4,5]
        };
        a.set("my_object", my_object);
        expect(a.get("my_object").key1).toEqual(my_object.key1);
        expect(a.get("my_object").key2).toEqual(my_object.key2);
        expect(a.get("my_object").key3[3]).toEqual(my_object.key3[3]);
    });

    it("should store and return nullness", function() {
        a.set("my_null", null);
        expect(a.get("my_null")).toBeNull();
    });

    it("should store and return integers", function() {
        a.set("my_int", 1);
        expect(a.get("my_int")).toEqual(1);
    });

    it("should increment and decrement stored integers", function() {
        a.set("my_int", 1);
        expect(a.get("my_int")).toEqual(1);
        a.incr("my_int");
        expect(a.get("my_int")).toEqual(2);
        a.decr("my_int");
        expect(a.get("my_int")).toEqual(1);
    });

    it("should remove stored values", function() {
        a.set("key", "value");
        a.remove("key");
        expect(a.get("key")).toBeNull();
    });

    it("should throw an error if attempting to store a function reference", function() {
        var fn = function() { return false; };
        expect(function() {a.set("my_func", fn)}).toThrow();
    });

    it("should be able to append a string to a string", function() {
        a.set("my_append", "Hello");
        expect(a.get("my_append")).toEqual("Hello");
        a.append("my_append", " World");
        expect(a.get("my_append")).toEqual("Hello World");
    });

    it("should be able to create a new value when attempting to append to null", function() {
        a.append("my_append", "Hello");
        expect(a.get("my_append")).toEqual("Hello");
    });

    it("should return length of new string from append method", function() {
        a.set("my_append", "Hello");
        expect(a.append("my_append", " World")).toEqual(11);
        expect(a.append("my_append", " Again")).toEqual(17);
        expect(a.get("my_append")).toEqual("Hello World Again");
    });

    it("should throw an error if attempting to append to a non-string type", function() {
        my_object = {"an": "object"};
        a.set("my_append", my_object);
        expect(function() {a.append("my_append", " World")}).toThrow();
    });

    describe("Increment function", function() {

        it("should allow for integers to be incremented", function() {
            a.set("my_incr", 7);
            expect(a.get("my_incr")).toEqual(7);
            a.incr("my_incr");
            expect(a.get("my_incr")).toEqual(8);
            a.incr("my_incr", 3);
            expect(a.get("my_incr")).toEqual(11);
        });

        it("should be able to get an incremented value", function() {
            a.set("my_incr", 1);
            expect(a.incr("my_incr")).toEqual(2);
            expect(a.get("my_incr")).toEqual(2);
        });

        it("should be able to increment a floating point value", function() {
            a.set("my_incr", 1.5);
            a.incr("my_incr");
            expect(a.get("my_incr")).toEqual(2.5);
        });

        it("should be able to increment an incorrect type. Really?", function() {
            a.set("my_incr", "bad string");
            a.incr("my_incr");
            expect(a.get("my_incr")).toEqual(1);
        });

        it("should be able to increment a null value", function() {
            a.incr("my_incr");
            expect(a.get("my_incr")).toEqual(1);
        });
    });

    describe("Decrement function", function() {

        it("should allow for integers to be decremented", function() {
            a.set("my_incr", 7);
            expect(a.get("my_incr")).toEqual(7);
            a.decr("my_incr");
            expect(a.get("my_incr")).toEqual(6);
            a.decr("my_incr", 3);
            expect(a.get("my_incr")).toEqual(3);
        });

        it("should allow for various random things. Huh?", function() {
            a.set("adh", 0);
            expect(a.decr("adh")).toEqual(-1);
            expect(a.decr("adh", 3)).toEqual(-4);
            expect(a.incr("adh", 10)).toEqual(6);
            expect(a.incr("adh")).toEqual(7);
        })
    });

    describe("Rename function", function() {

        it("should be able to rename keys", function() {
            a.set("key1", "value");
            a.rename("key1", "key2");
            expect(a.get("key2")).toEqual("value");
            expect(a.get("key1")).toBeNull();
        });

        it("should thow an error when renaming to the same key value", function() {
            a.set("key1", "value1");
            expect(function() { a.rename("key1", "key1"); }).toThrow();
        });

        it("should thow an error when renaming a non-existant key", function() {
            a.set("key1", "value1");
            expect(function() { a.rename("key2", "key1"); }).toThrow();
        });

    });

    describe("Strlength function", function() {

        it("should return the correct length of a string", function() {
            a.set("key1", "value");
            expect(a.strlength("key1")).toEqual(5);
        });

        it("should return 0 for length of a non-existant key", function() {
            expect(a.strlength("non-existant-key")).toEqual(0);
        });

        it("should throw an error if testing length of non-string type", function() {
            a.set("key1", [1,2,3,4,5]);
            expect(function() { a.strlength("key1") }).toThrow();
        });

    });

    describe("setnx function", function() {
        it("should return false if key already exists", function() {
            expect(a.setnx("key1", "value1")).toBeTruthy();
            expect(a.get("key1")).toEqual("value1");
            expect(a.setnx("key1", "value2")).toBeFalsy();
            expect(a.get("key1")).toEqual("value1");
        });
    });

    describe("getset function", function() {
        it("to return old value when setting new", function() {
            expect(a.getset("key1", "value1")).toBeNull();
            expect(a.getset("key1", "value2")).toEqual("value1");
            expect(a.get("key1")).toEqual("value2");
        })
    })

    describe("expiry functions", function() {
        // Asynchronous tests start here:
        xit("should lose expired values after the correct time", function() {
            a.set("key1", "value1", 500);
            expect(a.get("key1")).toEqual("value1");

            waits(1000);

            runs(function() {
                expect(a.get("key1")).not.toEqual("value1");
            });
        });

        xit("should lose expired values after the correct time when set using expires method", function() {
            a.set("key1", "value1");
            a.expire("key1", 500);
            expect(a.get("key1")).toEqual("value1");

            waits(1000);

            runs(function() {
                expect(a.get("key1")).not.toEqual("value1");
            });
        });

        xit("should persist values that were once set to expire", function() {
            a.set("key1", "value1");
            a.expire("key1", 500);

            waits(300);

            runs(function() {
                a.persist("key1");
            });

            waits(500);

            runs(function() {
                expect(a.get("key1")).toEqual("value1");
            });

        });
    });
});<commit_msg>Completed Jasmine test port.<commit_after>describe("SmartStorage", function() {

    var a, b;

    beforeEach(function() {
        // Kill any previous, and create two new storage objects.
        window.localStorage.clear();
        a = new SmartStorage("testdb1");
        b = new SmartStorage("testdb2");
        a.set("val1", "testval1");
        b.set("val1", "testval2");
    });

    it("should create two distinct storage objects", function() {
        expect(a.get("val1")).toEqual("testval1");
        expect(b.get("val1")).toEqual("testval2");
    });

    it("should store and return true/false values", function() {
        a.set("my_true", true);
        a.set("my_false", false);
        expect(a.get("my_true")).toBeTruthy();
        expect(a.get("my_false")).toBeFalsy();
    });

    it("should store and return string values", function() {
        a.set("val1", "testval1");
        a.set("val2", (new String("testval2")));
        expect(a.get("val1")).toEqual("testval1");
        expect(a.get("val2")).toEqual("testval2");
    });

    it("should store and return arrays", function() {
        my_array = [1,2,3,4,5];
        a.set("my_array", my_array);
        expect(a.get("my_array")[3]).toEqual(my_array[3]);
    });

    it("should store and return object/hash types", function() {
        my_object = {
            "key1": "value1",
            "key2": "value2",
            "key3": [1,2,3,4,5]
        };
        a.set("my_object", my_object);
        expect(a.get("my_object").key1).toEqual(my_object.key1);
        expect(a.get("my_object").key2).toEqual(my_object.key2);
        expect(a.get("my_object").key3[3]).toEqual(my_object.key3[3]);
    });

    it("should store and return nullness", function() {
        a.set("my_null", null);
        expect(a.get("my_null")).toBeNull();
    });

    it("should store and return integers", function() {
        a.set("my_int", 1);
        expect(a.get("my_int")).toEqual(1);
    });

    it("should increment and decrement stored integers", function() {
        a.set("my_int", 1);
        expect(a.get("my_int")).toEqual(1);
        a.incr("my_int");
        expect(a.get("my_int")).toEqual(2);
        a.decr("my_int");
        expect(a.get("my_int")).toEqual(1);
    });

    it("should remove stored values", function() {
        a.set("key", "value");
        a.remove("key");
        expect(a.get("key")).toBeNull();
    });

    it("should throw an error if attempting to store a function reference", function() {
        var fn = function() { return false; };
        expect(function() {a.set("my_func", fn)}).toThrow();
    });

    it("should be able to append a string to a string", function() {
        a.set("my_append", "Hello");
        expect(a.get("my_append")).toEqual("Hello");
        a.append("my_append", " World");
        expect(a.get("my_append")).toEqual("Hello World");
    });

    it("should be able to create a new value when attempting to append to null", function() {
        a.append("my_append", "Hello");
        expect(a.get("my_append")).toEqual("Hello");
    });

    it("should return length of new string from append method", function() {
        a.set("my_append", "Hello");
        expect(a.append("my_append", " World")).toEqual(11);
        expect(a.append("my_append", " Again")).toEqual(17);
        expect(a.get("my_append")).toEqual("Hello World Again");
    });

    it("should throw an error if attempting to append to a non-string type", function() {
        my_object = {"an": "object"};
        a.set("my_append", my_object);
        expect(function() {a.append("my_append", " World")}).toThrow();
    });

    describe("Increment function", function() {

        it("should allow for integers to be incremented", function() {
            a.set("my_incr", 7);
            expect(a.get("my_incr")).toEqual(7);
            a.incr("my_incr");
            expect(a.get("my_incr")).toEqual(8);
            a.incr("my_incr", 3);
            expect(a.get("my_incr")).toEqual(11);
        });

        it("should be able to get an incremented value", function() {
            a.set("my_incr", 1);
            expect(a.incr("my_incr")).toEqual(2);
            expect(a.get("my_incr")).toEqual(2);
        });

        it("should be able to increment a floating point value", function() {
            a.set("my_incr", 1.5);
            a.incr("my_incr");
            expect(a.get("my_incr")).toEqual(2.5);
        });

        it("should be able to increment an incorrect type. Really?", function() {
            a.set("my_incr", "bad string");
            a.incr("my_incr");
            expect(a.get("my_incr")).toEqual(1);
        });

        it("should be able to increment a null value", function() {
            a.incr("my_incr");
            expect(a.get("my_incr")).toEqual(1);
        });
    });

    describe("Decrement function", function() {

        it("should allow for integers to be decremented", function() {
            a.set("my_incr", 7);
            expect(a.get("my_incr")).toEqual(7);
            a.decr("my_incr");
            expect(a.get("my_incr")).toEqual(6);
            a.decr("my_incr", 3);
            expect(a.get("my_incr")).toEqual(3);
        });

        it("should allow for various random things. Huh?", function() {
            a.set("adh", 0);
            expect(a.decr("adh")).toEqual(-1);
            expect(a.decr("adh", 3)).toEqual(-4);
            expect(a.incr("adh", 10)).toEqual(6);
            expect(a.incr("adh")).toEqual(7);
        })
    });

    describe("Rename function", function() {

        it("should be able to rename keys", function() {
            a.set("key1", "value");
            a.rename("key1", "key2");
            expect(a.get("key2")).toEqual("value");
            expect(a.get("key1")).toBeNull();
        });

        it("should thow an error when renaming to the same key value", function() {
            a.set("key1", "value1");
            expect(function() { a.rename("key1", "key1"); }).toThrow();
        });

        it("should thow an error when renaming a non-existant key", function() {
            a.set("key1", "value1");
            expect(function() { a.rename("key2", "key1"); }).toThrow();
        });

    });

    describe("Strlength function", function() {

        it("should return the correct length of a string", function() {
            a.set("key1", "value");
            expect(a.strlength("key1")).toEqual(5);
        });

        it("should return 0 for length of a non-existant key", function() {
            expect(a.strlength("non-existant-key")).toEqual(0);
        });

        it("should throw an error if testing length of non-string type", function() {
            a.set("key1", [1,2,3,4,5]);
            expect(function() { a.strlength("key1") }).toThrow();
        });

    });

    describe("push functions", function() {

        it("should allow for values to be pushed on arrays", function() {
            a.set("key1", [1,2,3,4,5]);
            a.push("key1", "value1");
            expect(a.get("key1")[4]).toEqual(5);
            expect(a.get("key1")[5]).toEqual("value1");
        });

        it("should allow for creating array on a new key", function() {
            a.push("key1", "value1");
            expect(a.get("key1")[0]).toEqual("value1");
        });

        it("should throw an error if pushing on to a non array type", function() {
            a.set("key1", "a string");
            expect(function(){ a.push("key1", "value1"); }).toThrow();
        });

    });

    describe("pop functions", function() {

        it("should pop values off an array", function() {
            a.set("key1", [1,2,3,4,5]);
            expect(a.get("key1").length).toEqual(5);
            expect(a.pop("key1")).toEqual(5);
            expect(a.get("key1").length).toEqual(4);
        });

        it("should throw an error if trying to pop from non-existant key", function() {
            expect(function() { a.pop("key1"); }).toThrow();
        });

        it("should throw an error if trying to pop from non array type", function() {
            a.set("key1", "a string");
            expect(function() { a.pop("key1"); }).toThrow();
        });

    });

    describe("unshift functions", function() {

        it("should allow for values to be unshifted on arrays", function() {
            a.set("key1", [1,2,3,4,5]);
            a.unshift("key1", "value1");
            expect(a.get("key1")[5]).toEqual(5);
            expect(a.get("key1")[0]).toEqual("value1");
        });

        it("should allow for creating array on a new key", function() {
            a.unshift("key1", "value1");
            expect(a.get("key1")[0]).toEqual("value1");
        });

        it("should throw an error if unshifting on to a non array type", function() {
            a.set("key1", "a string");
            expect(function(){ a.unshift("key1", "value1"); }).toThrow();
        });

    });

    describe("shift functions", function() {

        it("should shift values off an array", function() {
            a.set("key1", [1,2,3,4,5]);
            expect(a.get("key1").length).toEqual(5);
            expect(a.shift("key1")).toEqual(1);
            expect(a.get("key1").length).toEqual(4);
        });

        it("should throw an error if trying to pop from non-existant key", function() {
            expect(function() { a.shift("key1"); }).toThrow();
        });

        it("should throw an error if trying to pop from non array type", function() {
            a.set("key1", "a string");
            expect(function() { a.shift("key1"); }).toThrow();
        });

    });

    describe("setnx function", function() {
        it("should return false if key already exists", function() {
            expect(a.setnx("key1", "value1")).toBeTruthy();
            expect(a.get("key1")).toEqual("value1");
            expect(a.setnx("key1", "value2")).toBeFalsy();
            expect(a.get("key1")).toEqual("value1");
        });
    });

    describe("getset function", function() {
        it("should return old value when setting new", function() {
            expect(a.getset("key1", "value1")).toBeNull();
            expect(a.getset("key1", "value2")).toEqual("value1");
            expect(a.get("key1")).toEqual("value2");
        })
    })

    describe("expiry functions", function() {
        // Asynchronous tests start here:
        xit("should lose expired values after the correct time", function() {
            a.set("key1", "value1", 500);
            expect(a.get("key1")).toEqual("value1");

            waits(1000);

            runs(function() {
                expect(a.get("key1")).not.toEqual("value1");
            });
        });

        xit("should lose expired values after the correct time when set using expires method", function() {
            a.set("key1", "value1");
            a.expire("key1", 500);
            expect(a.get("key1")).toEqual("value1");

            waits(1000);

            runs(function() {
                expect(a.get("key1")).not.toEqual("value1");
            });
        });

        xit("should persist values that were once set to expire", function() {
            a.set("key1", "value1");
            a.expire("key1", 500);

            waits(300);

            runs(function() {
                a.persist("key1");
            });

            waits(500);

            runs(function() {
                expect(a.get("key1")).toEqual("value1");
            });

        });
    });
});<|endoftext|>