<commit_before>import React, { Component } from 'react';
import { connect } from 'cerebral/react';
import queue_list from '../../computed/queue_list';
import QueueItem from './QueueItem/index';
import BigLoading from '../BigLoading/index';
import { Table, Segment } from 'semantic-ui-react';
require('./index.css');

export default connect(
  {
    queues_keys: queue_list(),
    is_loading: 'queue_tasks.is_loading',
    selected_task_key: 'queue_tasks.selected_task_key',
    list: 'queue_tasks.list',
  },
  {},
  class QueueTasks extends Component {

    _get_error_stack() {
      const selectedTaskKey = this.props.selected_task_key;
      const errorDetails = selectedTaskKey && this.props.list[ selectedTaskKey ]._error_details;
      if (selectedTaskKey && errorDetails) {
        return errorDetails.error_stack;
      }
      return null;
    }

    render() {
      return (

Tasks

firebase queue

          {this.props.is_loading ? (
            <BigLoading />
          ) : (
            <Segment id="queue-segment">

previous_state

error

date

                  {this.props.queues_keys.map((key) => (
                    <QueueItem
                      key={key}
                      itemKey={key}
                      task={this.props.list && this.props.list[ key ]}
                      selected_task_key={this.props.selected_task_key}
                    />
                  ))}

                {this._get_error_stack()}

            </Segment>
          )}

      );
    }
  }
)
<commit_msg>fix(queue): avoid errors on QueueTasks/index.js<commit_after>import React, { Component } from 'react';
import { connect } from 'cerebral/react';
import queue_list from '../../computed/queue_list';
import QueueItem from './QueueItem/index';
import BigLoading from '../BigLoading/index';
import { Table, Segment } from 'semantic-ui-react';
require('./index.css');

export default connect(
  {
    queues_keys: queue_list(),
    is_loading: 'queue_tasks.is_loading',
    selected_task_key: 'queue_tasks.selected_task_key',
    list: 'queue_tasks.list',
  },
  {},
  class QueueTasks extends Component {

    _get_error_stack() {
      const selectedTaskKey = this.props.selected_task_key;
      if (selectedTaskKey) {
        const task_item = this.props.list[selectedTaskKey];
        const error_details = task_item && task_item._error_details;
        return (error_details && error_details.error_stack) || null;
      }
      return null;
    }

    render() {
      return (

Tasks

firebase queue

          {this.props.is_loading ? (
            <BigLoading />
          ) : (
            <Segment id="queue-segment">

previous_state

error

date

                  {this.props.queues_keys.map((key) => (
                    <QueueItem
                      key={key}
                      itemKey={key}
                      task={this.props.list && this.props.list[ key ]}
                      selected_task_key={this.props.selected_task_key}
                    />
                  ))}

                {this._get_error_stack()}

            </Segment>
          )}

      );
    }
  }
)
<|endoftext|>


<commit_before>/**
 * This is our canonical implementation of the message types as defined in our official specification (message_types.ts)
 */

/* These fixed strings have to be stable and are intended to be
 * backwards/forwards compatible.  They are used in the computation of the
 * message fingerprint (for message id) and in the JSON serialization of our
 * messages to disk.  The actual classes that uses these typenames are free to
 * change their names or use inheritance/composition/whatever as long as they
 * eventually identify with one of these types.*/
var TYPENAME_TEXT_PART = "TextPart";
var TYPENAME_TAG_PAIR_BEGIN_REF = "TagPairBegin";
var TYPENAME_TAG_PAIR_END_REF = "TagPairEnd";
var TYPENAME_HTML_TAG_PAIR = "HtmlTagPair";

class TextPart {
  constructor(private value);
  getStableTypeName() {
    return TYPENAME_TEXT_PART;
  }
  toLongFingerprint() {
    return this.value;
  }
}

class Placeholder {
  constructor(private value);
}

class TagPairRefBase {
}

<commit_msg>delete unused/obsolete message_types.es6<commit_after><|endoftext|>


<commit_before>/**
 * Copyright 2013-2014 Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @providesModule PooledClass
 */

"use strict";

var invariant = require('invariant');

var ABOUT_POOLING_MESSAGE = null;
if (__DEV__) {
  ABOUT_POOLING_MESSAGE = (
    'This object is reused for performance reasons. If you\'re seeing this ' +
    'after logging an object, try logging individual properties.'
  );
}

/**
 * Static poolers. Several custom versions for each potential number of
 * arguments. A completely generic pooler is easy to implement, but would
 * require accessing the `arguments` object. In each of these, `this` refers to
 * the Class itself, not an instance. If any others are needed, simply add them
 * here, or in their own files.
 */
var oneArgumentPooler = function(copyFieldsFrom) {
  var Klass = this;
  var instance;
  if (Klass.instancePool.length) {
    instance = Klass.instancePool.pop();
    Klass.call(instance, copyFieldsFrom);
  } else {
    instance = new Klass(copyFieldsFrom);
  }
  instance._ABOUT_POOLING = null;
  return instance;
};

var twoArgumentPooler = function(a1, a2) {
  var Klass = this;
  var instance;
  if (Klass.instancePool.length) {
    instance = Klass.instancePool.pop();
    Klass.call(instance, a1, a2);
  } else {
    instance = new Klass(a1, a2);
  }
  instance._ABOUT_POOLING = null;
  return instance;
};

var threeArgumentPooler = function(a1, a2, a3) {
  var Klass = this;
  var instance;
  if (Klass.instancePool.length) {
    instance = Klass.instancePool.pop();
    Klass.call(instance, a1, a2, a3);
  } else {
    instance = new Klass(a1, a2, a3);
  }
  instance._ABOUT_POOLING = null;
  return instance;
};

var fiveArgumentPooler = function(a1, a2, a3, a4, a5) {
  var Klass = this;
  var instance;
  if (Klass.instancePool.length) {
    instance = Klass.instancePool.pop();
    Klass.call(instance, a1, a2, a3, a4, a5);
  } else {
    instance = new Klass(a1, a2, a3, a4, a5);
  }
  instance._ABOUT_POOLING = null;
  return instance;
};

var standardReleaser = function(instance) {
  var Klass = this;
  invariant(
    instance instanceof Klass,
    'Trying to release an instance into a pool of a different type.'
  );
  if (instance.destructor) {
    instance.destructor();
  }
  instance._ABOUT_POOLING = ABOUT_POOLING_MESSAGE;
  if (Klass.instancePool.length < Klass.poolSize) {
    Klass.instancePool.push(instance);
  }
};

var DEFAULT_POOL_SIZE = 10;
var DEFAULT_POOLER = oneArgumentPooler;

/**
 * Augments `CopyConstructor` to be a poolable class, augmenting only the class
 * itself (statically) not adding any prototypical fields. Any CopyConstructor
 * you give this may have a `poolSize` property, and will look for a
 * prototypical `destructor` on instances (optional).
 *
 * @param {Function} CopyConstructor Constructor that can be used to reset.
 * @param {Function} pooler Customizable pooler.
 */
var addPoolingTo = function(CopyConstructor, pooler) {
  var NewKlass = CopyConstructor;
  NewKlass.instancePool = [];
  NewKlass.getPooled = pooler || DEFAULT_POOLER;
  if (!NewKlass.poolSize) {
    NewKlass.poolSize = DEFAULT_POOL_SIZE;
  }
  NewKlass.release = standardReleaser;
  return NewKlass;
};

var PooledClass = {
  addPoolingTo: addPoolingTo,
  oneArgumentPooler: oneArgumentPooler,
  twoArgumentPooler: twoArgumentPooler,
  threeArgumentPooler: threeArgumentPooler,
  fiveArgumentPooler: fiveArgumentPooler
};

module.exports = PooledClass;
<commit_msg>Revert "Add helpful message about pooled classes"<commit_after>/**
 * Copyright 2013-2014 Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @providesModule PooledClass
 */

"use strict";

var invariant = require('invariant');

/**
 * Static poolers. Several custom versions for each potential number of
 * arguments. A completely generic pooler is easy to implement, but would
 * require accessing the `arguments` object. In each of these, `this` refers to
 * the Class itself, not an instance. If any others are needed, simply add them
 * here, or in their own files.
 */
var oneArgumentPooler = function(copyFieldsFrom) {
  var Klass = this;
  if (Klass.instancePool.length) {
    var instance = Klass.instancePool.pop();
    Klass.call(instance, copyFieldsFrom);
    return instance;
  } else {
    return new Klass(copyFieldsFrom);
  }
};

var twoArgumentPooler = function(a1, a2) {
  var Klass = this;
  if (Klass.instancePool.length) {
    var instance = Klass.instancePool.pop();
    Klass.call(instance, a1, a2);
    return instance;
  } else {
    return new Klass(a1, a2);
  }
};

var threeArgumentPooler = function(a1, a2, a3) {
  var Klass = this;
  if (Klass.instancePool.length) {
    var instance = Klass.instancePool.pop();
    Klass.call(instance, a1, a2, a3);
    return instance;
  } else {
    return new Klass(a1, a2, a3);
  }
};

var fiveArgumentPooler = function(a1, a2, a3, a4, a5) {
  var Klass = this;
  if (Klass.instancePool.length) {
    var instance = Klass.instancePool.pop();
    Klass.call(instance, a1, a2, a3, a4, a5);
    return instance;
  } else {
    return new Klass(a1, a2, a3, a4, a5);
  }
};

var standardReleaser = function(instance) {
  var Klass = this;
  invariant(
    instance instanceof Klass,
    'Trying to release an instance into a pool of a different type.'
  );
  if (instance.destructor) {
    instance.destructor();
  }
  if (Klass.instancePool.length < Klass.poolSize) {
    Klass.instancePool.push(instance);
  }
};

var DEFAULT_POOL_SIZE = 10;
var DEFAULT_POOLER = oneArgumentPooler;

/**
 * Augments `CopyConstructor` to be a poolable class, augmenting only the class
 * itself (statically) not adding any prototypical fields. Any CopyConstructor
 * you give this may have a `poolSize` property, and will look for a
 * prototypical `destructor` on instances (optional).
 *
 * @param {Function} CopyConstructor Constructor that can be used to reset.
 * @param {Function} pooler Customizable pooler.
 */
var addPoolingTo = function(CopyConstructor, pooler) {
  var NewKlass = CopyConstructor;
  NewKlass.instancePool = [];
  NewKlass.getPooled = pooler || DEFAULT_POOLER;
  if (!NewKlass.poolSize) {
    NewKlass.poolSize = DEFAULT_POOL_SIZE;
  }
  NewKlass.release = standardReleaser;
  return NewKlass;
};

var PooledClass = {
  addPoolingTo: addPoolingTo,
  oneArgumentPooler: oneArgumentPooler,
  twoArgumentPooler: twoArgumentPooler,
  threeArgumentPooler: threeArgumentPooler,
  fiveArgumentPooler: fiveArgumentPooler
};

module.exports = PooledClass;
<|endoftext|>


<commit_before>'use strict';

const OFF = 'off';
const ERROR = 'error';
const WARN = 'warn';

const COMPLEXITY_MAX = 5;
const TABWIDTH = 2;
const NESTED_CALLBACK_MAX = 4;
const ARGUMENTS_MAX = 4;

module.exports = {
  extends: 'eslint:recommended',
  env: {
    node: true,
  },
  globals: {
    require: false,
    module: false,
  },
  parserOptions: {
    ecmaVersion: 6,
    sourceType: 'script',
    arrowFunctions: true,
    binaryLiterals: true,
    blockBindings: true,
    classes: false,
    defaultParams: true,
    destructuring: true,
    forOf: true,
    generators: false,
    modules: false,
    objectLiteralComputedProperties: true,
    objectLiteralDuplicateProperties: true,
    objectLiteralShorthandMethods: true,
    objectLiteralShorthandProperties: true,
    octalLiterals: false,
    regexUFlag: true,
    regexYFlag: true,
    restParams: true,
    spread: true,
    superInFunctions: true,
    templateStrings: true,
    unicodeCodePointEscapes: true,
  },
  rules: {
    'accessor-pairs': [
      ERROR,
      { getWithoutSet: false, setWithoutGet: true },
    ],
    'array-bracket-spacing': [
      ERROR,
      'never',
    ],
    'array-callback-return': ERROR,
    'arrow-body-style': [
      ERROR,
      'as-needed',
    ],
    'arrow-parens': [
      ERROR,
      'as-needed',
      { requireForBlockBody: true },
    ],
    'arrow-spacing': ERROR,
    'block-spacing': [
      ERROR,
      'always',
    ],
    'brace-style': OFF,
    'callback-return': [
      ERROR, [
        'callback',
        'cb',
        'next',
        'done',
      ],
    ],
    camelcase: OFF,
    'capitalized-comments': OFF,
    'class-methods-use-this': ERROR,
    'comma-dangle': [
      ERROR,
      'always-multiline',
    ],
    'comma-spacing': [
      ERROR,
      { before: false, after: true },
    ],
    'comma-style': [
      ERROR,
      'last',
    ],
    complexity: [
      WARN,
      COMPLEXITY_MAX,
    ],
    'computed-property-spacing': [
      ERROR,
      'never',
    ],
    'consistent-return': ERROR,
    'consistent-this': [
      ERROR,
      '_this',
    ],
    'constructor-super': ERROR,
    curly: ERROR,
    'default-case': ERROR,
    'dot-location': [
      ERROR,
      'property',
    ],
    'dot-notation': ERROR,
    'eol-last': ERROR,
    eqeqeq: [
      ERROR,
      'smart',
    ],
    'func-call-spacing': [
      ERROR,
      'never',
    ],
    'func-names': WARN,
    'func-name-matching': OFF,
    'func-style': [
      ERROR,
      'declaration',
      { allowArrowFunctions: true },
    ],
    'global-require': ERROR,
    'guard-for-in': ERROR,
    'handle-callback-err': ERROR,
    'id-blacklist': OFF,
    'id-length': OFF,
    'id-match': OFF,
    indent: [
      ERROR,
      TABWIDTH,
      { SwitchCase: 1 },
    ],
    'init-declarations': OFF,
    'jsx-quotes': OFF,
    'key-spacing': [
      ERROR,
      { beforeColon: false, afterColon: true },
    ],
    'line-comment-position': OFF,
    'linebreak-style': [ERROR, 'unix'],
    'lines-around-comment': OFF,
    'lines-around-directive': OFF,
    'max-len': [
      WARN,
      100,
      TABWIDTH,
      {
        ignoreComments: true,
        ignorePattern: '^\\s+import\\s.+\\sfrom\\s.+;$',
      },
    ],
    'max-lines': [
      WARN,
      { max: 1000 },
    ],
    'max-nested-callbacks': [
      ERROR,
      NESTED_CALLBACK_MAX,
    ],
    'max-params': [
      ERROR,
      ARGUMENTS_MAX,
    ],
    'max-statements-per-line': [
      WARN,
      { max: 2 },
    ],
    'multiline-ternary': OFF,
    'new-cap': [
      ERROR,
      { newIsCap: true, capIsNew: true },
    ],
    'new-parens': ERROR,
    'newline-after-var': WARN,
    'newline-before-return': OFF,
    'newline-per-chained-call': [
      WARN,
      { ignoreChainWithDepth: 2 },
    ],
    'no-alert': ERROR,
    'no-array-constructor': ERROR,
    'no-await-in-loop': ERROR,
    'no-caller': ERROR,
    'no-case-declarations': ERROR,
    'no-catch-shadow': ERROR,
    'no-class-assign': ERROR,
    'no-confusing-arrow': OFF,
    'no-cond-assign': ERROR,
    'no-console': ERROR,
    'no-const-assign': ERROR,
    'no-constant-condition': ERROR,
    'no-continue': OFF,
    'no-control-regex': ERROR,
    'no-debugger': ERROR,
    'no-delete-var': ERROR,
    'no-div-regex': ERROR,
    'no-dupe-args': ERROR,
    'no-dupe-class-members': OFF,
    'no-dupe-keys': ERROR,
    'no-duplicate-case': ERROR,
    'no-duplicate-imports': ERROR,
    'no-else-return': ERROR,
    'no-empty': ERROR,
    'no-empty-character-class': ERROR,
    'no-empty-pattern': ERROR,
    'no-global-assign': ERROR,
    'no-labels': ERROR,
    'no-eq-null': ERROR,
    'no-eval': ERROR,
    'no-ex-assign': ERROR,
    'no-extend-native': ERROR,
    'no-extra-bind': ERROR,
    'no-extra-boolean-cast': ERROR,
    'no-extra-label': OFF,
    'no-extra-parens': OFF,
    'no-extra-semi': ERROR,
    'no-fallthrough': ERROR,
    'no-floating-decimal': ERROR,
    'no-func-assign': ERROR,
    'no-implicit-coercion': OFF,
    'no-implicit-globals': OFF,
    'no-implied-eval': ERROR,
    'no-inline-comments': OFF,
    'no-inner-declarations': ERROR,
    'no-invalid-regexp': ERROR,
    'no-invalid-this': WARN,
    'no-irregular-whitespace': ERROR,
    'no-iterator': ERROR,
    'no-label-var': ERROR,
    'no-lone-blocks': ERROR,
    'no-lonely-if': ERROR,
    'no-loop-func': ERROR,
    'no-magic-numbers': [
      ERROR,
      {
        ignoreArrayIndexes: true,
        ignore: [
          -1,
          0, 1,
          100, 101, 102,
          200, 201, 202, 203, 204, 205, 206, 207, 210, 226,
          300, 301, 302, 303, 304, 305, 306, 307, 308, 310,
          400, 401, 402, 403, 404, 405, 406, 407, 408, 409,
          410, 411, 412, 413, 414, 415, 416, 417, 418,
          421, 422, 423, 424, 425, 426, 427, 428, 429,
          431, 449, 450, 451, 456, 499,
          500, 501, 502, 503, 504, 505, 506, 507, 508, 509,
          510, 511, 520,
        ],
      },
    ],
    'no-mixed-operators': [
      ERROR,
      { allowSamePrecedence: false },
    ],
    'no-mixed-requires': OFF,
    'no-mixed-spaces-and-tabs': ERROR,
    'no-multi-spaces': ERROR,
    'no-multi-str': ERROR,
    'no-multiple-empty-lines': [
      ERROR,
      { max: 2 },
    ],
    'no-native-reassign': ERROR,
    'no-negated-condition': OFF,
    'no-negated-in-lhs': ERROR,
    'no-nested-ternary': OFF,
    'no-new': WARN,
    'no-new-func': ERROR,
    'no-new-object': ERROR,
    'no-new-require': ERROR,
    'no-new-symbol': ERROR,
    'no-obj-calls': ERROR,
    'no-octal': ERROR,
    'no-octal-escape': ERROR,
    'no-param-reassign': OFF,
    'no-path-concat': ERROR,
    'no-process-env': OFF,
    'no-process-exit': OFF,
    'no-proto': ERROR,
    'no-prototype-builtins': WARN,
    'no-redeclare': ERROR,
    'no-regex-spaces': ERROR,
    'no-reserved-keys': OFF,
    'no-restricted-globals': OFF,
    'no-restricted-imports': OFF,
    'no-restricted-modules': OFF,
    'no-restricted-syntax': OFF,
    'no-restricted-properties': [
      ERROR,
      {
        object: 'describe',
        property: 'only',
        message: 'Using describe.only is not allowed',
      }, {
        object: 'it',
        property: 'only',
        message: 'Using it.only is not allowed',
      },
    ],
    'no-return-assign': ERROR,
    'no-return-await': ERROR,
    'no-script-url': ERROR,
    'no-self-assign': ERROR,
    'no-self-compare': ERROR,
    'no-sequences': ERROR,
    'no-shadow': WARN,
    'no-shadow-restricted-names': ERROR,
    'no-spaced-func': ERROR,
    'no-sparse-arrays': ERROR,
    'no-sync': OFF,
    'no-tabs': ERROR,
    'no-ternary': OFF,
    'no-template-curly-in-string': WARN,
    'no-throw-literal': ERROR,
    'no-this-before-super': ERROR,
    'no-trailing-spaces': ERROR,
    'no-undef': ERROR,
    'no-undef-init': ERROR,
    'no-undefined': ERROR,
    'no-underscore-dangle': OFF,
    'no-unexpected-multiline': ERROR,
    'no-unmodified-loop-condition': ERROR,
    'no-unneeded-ternary': ERROR,
    'no-unreachable': ERROR,
    'no-unsafe-finally': ERROR,
    'no-unsafe-negation': ERROR,
    'no-unused-expressions': ERROR,
    'no-unused-labels': OFF,
    'no-unused-vars': [
      ERROR,
      { args: 'none' },
    ],
    'no-use-before-define': [
      ERROR,
      'nofunc',
    ],
    'no-useless-call': ERROR,
    'no-useless-computed-key': ERROR,
    'no-useless-concat': ERROR,
    'no-useless-constructor': ERROR,
    'no-useless-escape': WARN,
    'no-useless-rename': WARN,
    'no-useless-return': ERROR,
    'no-void': ERROR,
    'no-warning-comments': OFF,
    'no-with': ERROR,
    'no-whitespace-before-property': WARN,
    'object-curly-newline': OFF,
    'object-curly-spacing': [
      ERROR,
      'always',
    ],
    'object-property-newline': [
      ERROR,
      { allowMultiplePropertiesPerLine: true },
    ],
    'one-var': [
      ERROR,
      'never',
    ],
    'one-var-declaration-per-line': OFF,
    'operator-assignment': [
      ERROR,
      'always',
    ],
    'operator-linebreak': [
      ERROR,
      'after',
    ],
    'padded-blocks': OFF,
    'prefer-arrow-callback': OFF,
    'prefer-destructuring': OFF,
    'prefer-numeric-literals': ERROR,
    'prefer-reflect': OFF,
    'prefer-rest-params': WARN,
    'prefer-spread': OFF,
    'prefer-template': OFF,
    'quote-props': [
      ERROR,
      'as-needed',
    ],
    quotes: [
      ERROR,
      'single',
    ],
    radix: ERROR,
    'require-await': WARN,
    'require-jsdoc': OFF,
    'require-yield': ERROR,
    'rest-spread-spacing': [
      ERROR,
      'never',
    ],
    semi: [
      ERROR,
      'always',
    ],
    'semi-spacing': [
      ERROR,
      { before: false, after: true },
    ],
    'sort-imports': OFF,
    'sort-keys': OFF,
    'sort-vars': OFF,
    'space-after-keywords': OFF,
    'space-before-blocks': [
      ERROR,
      'always',
    ],
    'space-before-function-paren': [
      ERROR,
      'never',
    ],
    'keyword-spacing': [
      'error',
      {
        before: true,
        after: true,
        overrides: {
          if: { after: false },
          for: { after: false },
          while: { after: false },
        },
      },
    ],
    'space-in-parens': [
      ERROR,
      'never',
    ],
    'space-infix-ops': ERROR,
    'space-unary-ops': ERROR,
    'spaced-comment': [
      ERROR,
      'always',
    ],
    'symbol-description': ERROR,
    'template-curly-spacing': [
      ERROR,
      'never',
    ],
    'template-tag-spacing': OFF,
    'unicode-bom': ERROR,
    'valid-jsdoc': ERROR,
    'valid-typeof': ERROR,
    'vars-on-top': ERROR,
    'wrap-iife': ERROR,
    'wrap-regex': ERROR,
    yoda: [
      ERROR,
      'always',
    ],
  },
};
<commit_msg>feat(eslint): add eslint 3.17 rules<commit_after>'use strict';

const OFF = 'off';
const ERROR = 'error';
const WARN = 'warn';

const COMPLEXITY_MAX = 5;
const TABWIDTH = 2;
const NESTED_CALLBACK_MAX = 4;
const ARGUMENTS_MAX = 4;

module.exports = {
  extends: 'eslint:recommended',
  env: {
    node: true,
  },
  globals: {
    require: false,
    module: false,
  },
  parserOptions: {
    ecmaVersion: 6,
    sourceType: 'script',
    arrowFunctions: true,
    binaryLiterals: true,
    blockBindings: true,
    classes: false,
    defaultParams: true,
    destructuring: true,
    forOf: true,
    generators: false,
    modules: false,
    objectLiteralComputedProperties: true,
    objectLiteralDuplicateProperties: true,
    objectLiteralShorthandMethods: true,
    objectLiteralShorthandProperties: true,
    octalLiterals: false,
    regexUFlag: true,
    regexYFlag: true,
    restParams: true,
    spread: true,
    superInFunctions: true,
    templateStrings: true,
    unicodeCodePointEscapes: true,
  },
  rules: {
    'accessor-pairs': [
      ERROR,
      { getWithoutSet: false, setWithoutGet: true },
    ],
    'array-bracket-spacing': [
      ERROR,
      'never',
    ],
    'array-callback-return': ERROR,
    'arrow-body-style': [
      ERROR,
      'as-needed',
    ],
    'arrow-parens': [
      ERROR,
      'as-needed',
      { requireForBlockBody: true },
    ],
    'arrow-spacing': ERROR,
    'block-spacing': [
      ERROR,
      'always',
    ],
    'brace-style': OFF,
    'callback-return': [
      ERROR, [
        'callback',
        'cb',
        'next',
        'done',
      ],
    ],
    camelcase: OFF,
    'capitalized-comments': OFF,
    'class-methods-use-this': ERROR,
    'comma-dangle': [
      ERROR,
      'always-multiline',
    ],
    'comma-spacing': [
      ERROR,
      { before: false, after: true },
    ],
    'comma-style': [
      ERROR,
      'last',
    ],
    complexity: [
      WARN,
      COMPLEXITY_MAX,
    ],
    'computed-property-spacing': [
      ERROR,
      'never',
    ],
    'consistent-return': ERROR,
    'consistent-this': [
      ERROR,
      '_this',
    ],
    'constructor-super': ERROR,
    curly: ERROR,
    'default-case': ERROR,
    'dot-location': [
      ERROR,
      'property',
    ],
    'dot-notation': ERROR,
    'eol-last': ERROR,
    eqeqeq: [
      ERROR,
      'smart',
    ],
    'func-call-spacing': [
      ERROR,
      'never',
    ],
    'func-names': WARN,
    'func-name-matching': OFF,
    'func-style': [
      ERROR,
      'declaration',
      { allowArrowFunctions: true },
    ],
    'global-require': ERROR,
    'guard-for-in': ERROR,
    'handle-callback-err': ERROR,
    'id-blacklist': OFF,
    'id-length': OFF,
    'id-match': OFF,
    indent: [
      ERROR,
      TABWIDTH,
      { SwitchCase: 1 },
    ],
    'init-declarations': OFF,
    'jsx-quotes': OFF,
    'key-spacing': [
      ERROR,
      { beforeColon: false, afterColon: true },
    ],
    'line-comment-position': OFF,
    'linebreak-style': [ERROR, 'unix'],
    'lines-around-comment': OFF,
    'lines-around-directive': OFF,
    'max-len': [
      WARN,
      100,
      TABWIDTH,
      {
        ignoreComments: true,
        ignorePattern: '^\\s+import\\s.+\\sfrom\\s.+;$',
      },
    ],
    'max-lines': [
      WARN,
      { max: 1000 },
    ],
    'max-nested-callbacks': [
      ERROR,
      NESTED_CALLBACK_MAX,
    ],
    'max-params': [
      ERROR,
      ARGUMENTS_MAX,
    ],
    'max-statements-per-line': [
      WARN,
      { max: 2 },
    ],
    'multiline-ternary': OFF,
    'new-cap': [
      ERROR,
      { newIsCap: true, capIsNew: true },
    ],
    'new-parens': ERROR,
    'newline-after-var': WARN,
    'newline-before-return': OFF,
    'newline-per-chained-call': [
      WARN,
      { ignoreChainWithDepth: 2 },
    ],
    'no-alert': ERROR,
    'no-array-constructor': ERROR,
    'no-await-in-loop': ERROR,
    'no-caller': ERROR,
    'no-case-declarations': ERROR,
    'no-catch-shadow': ERROR,
    'no-class-assign': ERROR,
    'no-compare-neg-zero': ERROR,
    'no-confusing-arrow': OFF,
    'no-cond-assign': ERROR,
    'no-console': ERROR,
    'no-const-assign': ERROR,
    'no-constant-condition': ERROR,
    'no-continue': OFF,
    'no-control-regex': ERROR,
    'no-debugger': ERROR,
    'no-delete-var': ERROR,
    'no-div-regex': ERROR,
    'no-dupe-args': ERROR,
    'no-dupe-class-members': OFF,
    'no-dupe-keys': ERROR,
    'no-duplicate-case': ERROR,
    'no-duplicate-imports': ERROR,
    'no-else-return': ERROR,
    'no-empty': ERROR,
    'no-empty-character-class': ERROR,
    'no-empty-pattern': ERROR,
    'no-global-assign': ERROR,
    'no-labels': ERROR,
    'no-eq-null': ERROR,
    'no-eval': ERROR,
    'no-ex-assign': ERROR,
    'no-extend-native': ERROR,
    'no-extra-bind': ERROR,
    'no-extra-boolean-cast': ERROR,
    'no-extra-label': OFF,
    'no-extra-parens': OFF,
    'no-extra-semi': ERROR,
    'no-fallthrough': ERROR,
    'no-floating-decimal': ERROR,
    'no-func-assign': ERROR,
    'no-implicit-coercion': OFF,
    'no-implicit-globals': OFF,
    'no-implied-eval': ERROR,
    'no-inline-comments': OFF,
    'no-inner-declarations': ERROR,
    'no-invalid-regexp': ERROR,
    'no-invalid-this': WARN,
    'no-irregular-whitespace': ERROR,
    'no-iterator': ERROR,
    'no-label-var': ERROR,
    'no-lone-blocks': ERROR,
    'no-lonely-if': ERROR,
    'no-loop-func': ERROR,
    'no-magic-numbers': [
      ERROR,
      {
        ignoreArrayIndexes: true,
        ignore: [
          -1,
          0, 1,
          100, 101, 102,
          200, 201, 202, 203, 204, 205, 206, 207, 210, 226,
          300, 301, 302, 303, 304, 305, 306, 307, 308, 310,
          400, 401, 402, 403, 404, 405, 406, 407, 408, 409,
          410, 411, 412, 413, 414, 415, 416, 417, 418,
          421, 422, 423, 424, 425, 426, 427, 428, 429,
          431, 449, 450, 451, 456, 499,
          500, 501, 502, 503, 504, 505, 506, 507, 508, 509,
          510, 511, 520,
        ],
      },
    ],
    'no-mixed-operators': [
      ERROR,
      { allowSamePrecedence: false },
    ],
    'no-mixed-requires': OFF,
    'no-mixed-spaces-and-tabs': ERROR,
    'no-multi-spaces': ERROR,
    'no-multi-str': ERROR,
    'no-multiple-empty-lines': [
      ERROR,
      { max: 2 },
    ],
    'no-native-reassign': ERROR,
    'no-negated-condition': OFF,
    'no-negated-in-lhs': ERROR,
    'no-nested-ternary': OFF,
    'no-new': WARN,
    'no-new-func': ERROR,
    'no-new-object': ERROR,
    'no-new-require': ERROR,
    'no-new-symbol': ERROR,
    'no-obj-calls': ERROR,
    'no-octal': ERROR,
    'no-octal-escape': ERROR,
    'no-param-reassign': OFF,
    'no-path-concat': ERROR,
    'no-process-env': OFF,
    'no-process-exit': OFF,
    'no-proto': ERROR,
    'no-prototype-builtins': WARN,
    'no-redeclare': ERROR,
    'no-regex-spaces': ERROR,
    'no-reserved-keys': OFF,
    'no-restricted-globals': OFF,
    'no-restricted-imports': OFF,
    'no-restricted-modules': OFF,
    'no-restricted-syntax': OFF,
    'no-restricted-properties': [
      ERROR,
      {
        object: 'describe',
        property: 'only',
        message: 'Using describe.only is not allowed',
      }, {
        object: 'it',
        property: 'only',
        message: 'Using it.only is not allowed',
      },
    ],
    'no-return-assign': ERROR,
    'no-return-await': ERROR,
    'no-script-url': ERROR,
    'no-self-assign': ERROR,
    'no-self-compare': ERROR,
    'no-sequences': ERROR,
    'no-shadow': WARN,
    'no-shadow-restricted-names': ERROR,
    'no-spaced-func': ERROR,
    'no-sparse-arrays': ERROR,
    'no-sync': OFF,
    'no-tabs': ERROR,
    'no-ternary': OFF,
    'no-template-curly-in-string': WARN,
    'no-throw-literal': ERROR,
    'no-this-before-super': ERROR,
    'no-trailing-spaces': ERROR,
    'no-undef': ERROR,
    'no-undef-init': ERROR,
    'no-undefined': ERROR,
    'no-underscore-dangle': OFF,
    'no-unexpected-multiline': ERROR,
    'no-unmodified-loop-condition': ERROR,
    'no-unneeded-ternary': ERROR,
    'no-unreachable': ERROR,
    'no-unsafe-finally': ERROR,
    'no-unsafe-negation': ERROR,
    'no-unused-expressions': ERROR,
    'no-unused-labels': OFF,
    'no-unused-vars': [
      ERROR,
      { args: 'none' },
    ],
    'no-use-before-define': [
      ERROR,
      'nofunc',
    ],
    'no-useless-call': ERROR,
    'no-useless-computed-key': ERROR,
    'no-useless-concat': ERROR,
    'no-useless-constructor': ERROR,
    'no-useless-escape': WARN,
    'no-useless-rename': WARN,
    'no-useless-return': ERROR,
    'no-void': ERROR,
    'no-warning-comments': OFF,
    'no-with': ERROR,
    'no-whitespace-before-property': WARN,
    'nonblock-statement-body-position': OFF,
    'object-curly-newline': OFF,
    'object-curly-spacing': [
      ERROR,
      'always',
    ],
    'object-property-newline': [
      ERROR,
      { allowMultiplePropertiesPerLine: true },
    ],
    'one-var': [
      ERROR,
      'never',
    ],
    'one-var-declaration-per-line': OFF,
    'operator-assignment': [
      ERROR,
      'always',
    ],
    'operator-linebreak': [
      ERROR,
      'after',
    ],
    'padded-blocks': OFF,
    'prefer-arrow-callback': OFF,
    'prefer-destructuring': OFF,
    'prefer-numeric-literals': ERROR,
    'prefer-reflect': OFF,
    'prefer-rest-params': WARN,
    'prefer-spread': OFF,
    'prefer-template': OFF,
    'quote-props': [
      ERROR,
      'as-needed',
    ],
    quotes: [
      ERROR,
      'single',
    ],
    radix: ERROR,
    'require-await': WARN,
    'require-jsdoc': OFF,
    'require-yield': ERROR,
    'rest-spread-spacing': [
      ERROR,
      'never',
    ],
    semi: [
      ERROR,
      'always',
    ],
    'semi-spacing': [
      ERROR,
      { before: false, after: true },
    ],
    'sort-imports': OFF,
    'sort-keys': OFF,
    'sort-vars': OFF,
    'space-after-keywords': OFF,
    'space-before-blocks': [
      ERROR,
      'always',
    ],
    'space-before-function-paren': [
      ERROR,
      'never',
    ],
    'keyword-spacing': [
      'error',
      {
        before: true,
        after: true,
        overrides: {
          if: { after: false },
          for: { after: false },
          while: { after: false },
        },
      },
    ],
    'space-in-parens': [
      ERROR,
      'never',
    ],
    'space-infix-ops': ERROR,
    'space-unary-ops': ERROR,
    'spaced-comment': [
      ERROR,
      'always',
    ],
    'symbol-description': ERROR,
    'template-curly-spacing': [
      ERROR,
      'never',
    ],
    'template-tag-spacing': OFF,
    'unicode-bom': ERROR,
    'valid-jsdoc': ERROR,
    'valid-typeof': ERROR,
    'vars-on-top': ERROR,
    'wrap-iife': ERROR,
    'wrap-regex': ERROR,
    yoda: [
      ERROR,
      'always',
    ],
  },
};
<|endoftext|>


<commit_before>const React = require('react');
const PropTypes = require('prop-types');
const Radium = require('radium');

const Icon = require('./Icon');

const { themeShape } = require('../constants/App');

const StyleUtils = require('../utils/Style');

class SelectFullScreen extends React.Component {
  static propTypes = {
    closeIcon: PropTypes.string,
    isFixed: PropTypes.bool,
    onChange: PropTypes.func,
    optionFormatter: PropTypes.func,
    options: PropTypes.array,
    optionsHeaderText: PropTypes.string,
    optionsStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
    optionStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
    placeholderText: PropTypes.string,
    selected: PropTypes.object,
    selectedStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
    theme: themeShape
  };

  static defaultProps = {
    closeIcon: 'close',
    isFixed: false,
    onChange () {},
    options: [],
    optionsHeaderText: 'Select An Option',
    placeholderText: 'Select One',
    selected: false
  };

  state = {
    isOpen: false,
    selected: false
  };

  componentDidMount () {
    window.onkeyup = e => {
      if (e.keyCode === 27) {
        this._handleCloseClick();
      }
    };
  }

  _handleClick = () => {
    this.setState({
      isOpen: true
    });
  };

  _handleCloseClick = () => {
    this.setState({
      isOpen: false
    });
  };

  _handleOptionClick = (option) => {
    this.setState({
      selected: option,
      isOpen: false
    });

    this.props.onChange(option);
  };

  _handleSelectChange = (e) => {
    const selectedOption = this.props.options.filter(option => {
      return option.value + '' === e.target.value;
    })[0];

    this._handleOptionClick(selectedOption);
  };

  _optionFormatter = (option, styles) => {
    return (

        {option.displayValue}

    );
  };

  _renderOptions = (styles) => {
    if (this.state.isOpen) {
      return (

            <Icon
              size={20}
              style={styles.closeIcon}
              type={this.props.closeIcon}
            />

ESC

              {this.props.optionsHeaderText}

              {this.props.options.map(option => {
                return (

                    {this.props.optionFormatter ? this.props.optionFormatter(option) : this._optionFormatter(option, styles)}

                );
              })}

      );
    } else {
      return null;
    }
  };

  render () {
    const theme = StyleUtils.mergeTheme(this.props.theme);
    const styles = this.styles(theme);
    const selected = this.state.selected || this.props.selected || { displayValue: this.props.placeholderText, value: '' };

    return (

          {selected.displayValue}

        {this._renderOptions(styles)}

    );
  }

  styles = (theme) => {
    return {
      close: {
        position: 'absolute',
        right: 20,
        top: 15,
        textAlign: 'center',
        cursor: 'pointer',
        color: theme.Colors.GRAY_500
      },
      closeIcon: {
        color: theme.Colors.GRAY_500
      },
      closeText: {
        fontSize: theme.FontSizes.TINY
      },
      component: {
        cursor: 'pointer',
        fontFamily: theme.FontFamily,
        fontSize: theme.FontSizes.LARGE,
        color: theme.Colors.GRAY_700,
        boxSizing: 'border-box',
        outline: 'none'
      },
      content: {
        left: '50%',
        position: 'absolute',
        top: '50%',
        transform: 'translate(-50%, -50%)',
        width: 300
      },
      optionsScrim: {
        backgroundColor: '#fff',
        bottom: 0,
        height: '100%',
        left: 0,
        position: 'absolute',
        right: 0,
        top: 0,
        zIndex: 999
      },
      optionsWrapper: {
        border: '1px solid ' + theme.Colors.GRAY_300,
        height: 250,
        overflow: 'auto',
        width: 300
      },
      option: {
        cursor: 'pointer',
        backgroundColor: '#fff',
        padding: 10,
        whiteSpace: 'nowrap',
        fontSize: theme.FontSizes.MEDIUM,

        ':hover': {
          backgroundColor: theme.Colors.PRIMARY,
          color: theme.Colors.WHITE,
          opacity: 1
        }
      },
      optionsHeader: {
        color: theme.Colors.GRAY_700,
        fontSize: theme.FontSizes.XXLARGE,
        fontWeight: 'bold',
        paddingBottom: 10
      }
    };
  }
}

module.exports = Radium(SelectFullScreen);
<commit_msg>added selectFullScreenRef<commit_after>const React = require('react');
const PropTypes = require('prop-types');
const Radium = require('radium');

const Icon = require('./Icon');

const { themeShape } = require('../constants/App');

const StyleUtils = require('../utils/Style');

class SelectFullScreen extends React.Component {
  static propTypes = {
    closeIcon: PropTypes.string,
    isFixed: PropTypes.bool,
    onChange: PropTypes.func,
    optionFormatter: PropTypes.func,
    options: PropTypes.array,
    optionsHeaderText: PropTypes.string,
    optionsStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
    optionStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
    placeholderText: PropTypes.string,
    selected: PropTypes.object,
    selectedStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
    selectFullScreenRef: PropTypes.func,
    theme: themeShape
  };

  static defaultProps = {
    closeIcon: 'close',
    isFixed: false,
    onChange () {},
    options: [],
    optionsHeaderText: 'Select An Option',
    placeholderText: 'Select One',
    selected: false
  };

  state = {
    isOpen: false,
    selected: false
  };

  componentDidMount () {
    window.onkeyup = e => {
      if (e.keyCode === 27) {
        this._handleCloseClick();
      }
    };
  }

  _handleClick = () => {
    this.setState({
      isOpen: true
    });
  };

  _handleCloseClick = () => {
    this.setState({
      isOpen: false
    });
  };

  _handleOptionClick = (option) => {
    this.setState({
      selected: option,
      isOpen: false
    });

    this.props.onChange(option);
  };

  _handleSelectChange = (e) => {
    const selectedOption = this.props.options.filter(option => {
      return option.value + '' === e.target.value;
    })[0];

    this._handleOptionClick(selectedOption);
  };

  _optionFormatter = (option, styles) => {
    return (

        {option.displayValue}

    );
  };

  _renderOptions = (styles) => {
    if (this.state.isOpen) {
      return (

            <Icon
              size={20}
              style={styles.closeIcon}
              type={this.props.closeIcon}
            />

ESC

              {this.props.optionsHeaderText}

              {this.props.options.map(option => {
                return (

                    {this.props.optionFormatter ? this.props.optionFormatter(option) : this._optionFormatter(option, styles)}

                );
              })}

      );
    } else {
      return null;
    }
  };

  render () {
    const theme = StyleUtils.mergeTheme(this.props.theme);
    const styles = this.styles(theme);
    const selected = this.state.selected || this.props.selected || { displayValue: this.props.placeholderText, value: '' };

    return (

          {selected.displayValue}

        {this._renderOptions(styles)}

    );
  }

  styles = (theme) => {
    return {
      close: {
        position: 'absolute',
        right: 20,
        top: 15,
        textAlign: 'center',
        cursor: 'pointer',
        color: theme.Colors.GRAY_500
      },
      closeIcon: {
        color: theme.Colors.GRAY_500
      },
      closeText: {
        fontSize: theme.FontSizes.TINY
      },
      component: {
        cursor: 'pointer',
        fontFamily: theme.FontFamily,
        fontSize: theme.FontSizes.LARGE,
        color: theme.Colors.GRAY_700,
        boxSizing: 'border-box',
        outline: 'none'
      },
      content: {
        left: '50%',
        position: 'absolute',
        top: '50%',
        transform: 'translate(-50%, -50%)',
        width: 300
      },
      optionsScrim: {
        backgroundColor: '#fff',
        bottom: 0,
        height: '100%',
        left: 0,
        position: 'absolute',
        right: 0,
        top: 0,
        zIndex: 999
      },
      optionsWrapper: {
        border: '1px solid ' + theme.Colors.GRAY_300,
        height: 250,
        overflow: 'auto',
        width: 300
      },
      option: {
        cursor: 'pointer',
        backgroundColor: '#fff',
        padding: 10,
        whiteSpace: 'nowrap',
        fontSize: theme.FontSizes.MEDIUM,

        ':hover': {
          backgroundColor: theme.Colors.PRIMARY,
          color: theme.Colors.WHITE,
          opacity: 1
        }
      },
      optionsHeader: {
        color: theme.Colors.GRAY_700,
        fontSize: theme.FontSizes.XXLARGE,
        fontWeight: 'bold',
        paddingBottom: 10
      }
    };
  }
}

module.exports = Radium(SelectFullScreen);
<|endoftext|>


<commit_before>/* global assert, setup, suite, test */
var entityFactory = require('../helpers').entityFactory;
var THREE = require('index').THREE;

suite('shadow component', function () {
  var component;
  var el;
  var mesh;

  setup(function (done) {
    el = entityFactory();
    el.addEventListener('componentinitialized', function (evt) {
      if (evt.detail.name !== 'shadow') { return; }
      component = el.components.shadow;
      done();
    });
    el.setAttribute('shadow', {});
    mesh = new THREE.Mesh(
      new THREE.Sphere(2),
      new THREE.MeshBasicMaterial({color: 0xffff00})
    );
  });

  suite('update', function () {
    test('sets cast and receive properties on meshes', function () {
      el.object3D.add(mesh);
      component.update();
      assert.ok(mesh.castShadow);
      assert.ok(mesh.receiveShadow);
      el.setAttribute('shadow', {cast: true, receive: false});
      assert.ok(mesh.castShadow);
      assert.notOk(mesh.receiveShadow);
      el.setAttribute('shadow', {cast: false, receive: false});
      assert.notOk(mesh.castShadow);
      assert.notOk(mesh.receiveShadow);
    });

    test('sets needsUpdate on material', function () {
      el.object3D.add(mesh);
      mesh.material.needsUpdate = false;
      component.update();
      assert.ok(mesh.material.needsUpdate);
    });

    test('sets needsUpdate on material array', function () {
      var mesh2 = new THREE.Mesh(
        new THREE.Sphere(2),
        [new THREE.MeshBasicMaterial({color: 0xffff00}),
          new THREE.MeshBasicMaterial({color: 0xffff00})]
      );
      el.object3D.add(mesh2);
      mesh2.material[0].needsUpdate = false;
      mesh2.material[1].needsUpdate = false;
      component.update();
      assert.ok(mesh2.material[0].needsUpdate && mesh2.material[1].needsUpdate);
    });

    test('refreshes after setObject3D', function () {
      el.setObject3D('foo', mesh);
      component.update();
      assert.ok(mesh.castShadow);
      assert.ok(mesh.receiveShadow);
    });
  });

  suite('remove', function () {
    test('cleans up shadow references', function () {
      el.object3D.add(mesh);
      component.update();
      assert.ok(mesh.castShadow);
      assert.ok(mesh.receiveShadow);
      el.removeAttribute('shadow');
      assert.notOk(mesh.castShadow);
      assert.notOk(mesh.receiveShadow);
    });
  });
});
<commit_msg>Move meshWithMaterialArray creation to setup in shadow component test<commit_after>/* global assert, setup, suite, test */
var entityFactory = require('../helpers').entityFactory;
var THREE = require('index').THREE;

suite('shadow component', function () {
  var component;
  var el;
  var mesh;
  var meshWithMaterialArray;

  setup(function (done) {
    el = entityFactory();
    el.addEventListener('componentinitialized', function (evt) {
      if (evt.detail.name !== 'shadow') { return; }
      component = el.components.shadow;
      done();
    });
    el.setAttribute('shadow', {});
    mesh = new THREE.Mesh(
      new THREE.Sphere(2),
      new THREE.MeshBasicMaterial({color: 0xffff00})
    );
    meshWithMaterialArray = new THREE.Mesh(
      new THREE.Sphere(2),
      [new THREE.MeshBasicMaterial({color: 0xffff00}),
        new THREE.MeshBasicMaterial({color: 0xffff00})]
    );
  });

  suite('update', function () {
    test('sets cast and receive properties on meshes', function () {
      el.object3D.add(mesh);
      component.update();
      assert.ok(mesh.castShadow);
      assert.ok(mesh.receiveShadow);
      el.setAttribute('shadow', {cast: true, receive: false});
      assert.ok(mesh.castShadow);
      assert.notOk(mesh.receiveShadow);
      el.setAttribute('shadow', {cast: false, receive: false});
      assert.notOk(mesh.castShadow);
      assert.notOk(mesh.receiveShadow);
    });

    test('sets needsUpdate on material', function () {
      el.object3D.add(mesh);
      mesh.material.needsUpdate = false;
      component.update();
      assert.ok(mesh.material.needsUpdate);
    });

    test('sets needsUpdate on material array', function () {
      el.object3D.add(meshWithMaterialArray);
      meshWithMaterialArray.material[0].needsUpdate = false;
      meshWithMaterialArray.material[1].needsUpdate = false;
      component.update();
      assert.ok(meshWithMaterialArray.material[0].needsUpdate &&
        meshWithMaterialArray.material[1].needsUpdate);
    });

    test('refreshes after setObject3D', function () {
      el.setObject3D('foo', mesh);
      component.update();
      assert.ok(mesh.castShadow);
      assert.ok(mesh.receiveShadow);
    });
  });

  suite('remove', function () {
    test('cleans up shadow references', function () {
      el.object3D.add(mesh);
      component.update();
      assert.ok(mesh.castShadow);
      assert.ok(mesh.receiveShadow);
      el.removeAttribute('shadow');
      assert.notOk(mesh.castShadow);
      assert.notOk(mesh.receiveShadow);
    });
  });
});
<|endoftext|>


<commit_before>"use strict";

const assert               = require('assert');

const defs                 = require('./defs.js');
const lobject              = require('./lobject.js');
const ldo                  = require('./ldo.js');
const lapi                 = require('./lapi.js');
const ltable               = require('./ltable.js');
const lfunc                = require('./lfunc.js');
const ltm                  = require('./ltm.js');
const CT                   = defs.constant_types;
const TS                   = defs.thread_status;
const LUA_NUMTAGS          = CT.LUA_NUMTAGS;

const EXTRA_STACK = 5;

const BASIC_STACK_SIZE = 2 * defs.LUA_MINSTACK;

class CallInfo {

    constructor() {
        this.func = null;
        this.funcOff = NaN;
        this.top = NaN;
        this.previous = null;
        this.next = null;

        /* only for Lua functions */
        this.l_base = NaN; /* base for this function */
        this.l_code = null; /* reference to this.func.p.code */
        this.l_savedpc = NaN; /* offset into l_code */
        /* only for JS functions */
        this.c_k = null;  /* continuation in case of yields */
        this.c_old_errfunc = null;
        this.c_ctx = null;  /* context info. in case of yields */

        this.nresults = NaN;
        this.callstatus = NaN;
    }

}

class lua_State {

    constructor(g) {
        this.id = g.id_counter++;

        this.base_ci = new CallInfo(); /* CallInfo for first level (C calling Lua) */
        this.top = NaN; /* first free slot in the stack */
        this.stack_last = NaN; /* last free slot in the stack */
        this.oldpc = NaN; /* last pc traced */

        /* preinit_thread */
        this.l_G = g;
        this.stack = null;
        this.ci = null;
        this.errorJmp = null;
        this.nCcalls = 0;
        this.hook = null;
        this.hookmask = 0;
        this.basehookcount = 0;
        this.allowhook = 1;
        this.hookcount = this.basehookcount;
        this.openupval = null;
        this.nny = 1;
        this.status = TS.LUA_OK;
        this.errfunc = 0;
    }

}

class global_State {

    constructor() {
        this.id_counter = 0; /* used to give objects unique ids */
        this.ids = new WeakMap();

        this.mainthread = null;
        this.l_registry = new lobject.TValue(CT.LUA_TNIL, null);
        this.panic = null;
        this.atnativeerror = null;
        this.version = null;
        this.tmname = new Array(ltm.TMS.TM_N);
        this.mt = new Array(LUA_NUMTAGS);
    }

}

const luaE_extendCI = function(L) {
    let ci = new CallInfo();
    L.ci.next = ci;
    ci.previous = L.ci;
    ci.next = null;
    L.ci = ci;
    return ci;
};

const luaE_freeCI = function(L) {
    let ci = L.ci;
    ci.next = null;
};

const stack_init = function(L1, L) {
    L1.stack = new Array(BASIC_STACK_SIZE);
    L1.top = 0;
    L1.stack_last = BASIC_STACK_SIZE - EXTRA_STACK;
    /* initialize first ci */
    let ci = L1.base_ci;
    ci.next = ci.previous = null;
    ci.callstatus = 0;
    ci.funcOff = L1.top;
    ci.func = L1.stack[L1.top];
    L1.stack[L1.top++] = new lobject.TValue(CT.LUA_TNIL, null);
    ci.top = L1.top + defs.LUA_MINSTACK;
    L1.ci = ci;
};

const freestack = function(L) {
    L.ci = L.base_ci;
    luaE_freeCI(L);
    L.stack = null;
};

/*
** Create registry table and its predefined values
*/
const init_registry = function(L, g) {
    let registry = ltable.luaH_new(L);
    g.l_registry.sethvalue(registry);
    ltable.luaH_setint(registry, defs.LUA_RIDX_MAINTHREAD, new lobject.TValue(CT.LUA_TTHREAD, L));
    ltable.luaH_setint(registry, defs.LUA_RIDX_GLOBALS, new lobject.TValue(CT.LUA_TTABLE, ltable.luaH_new(L)));
};

/*
** open parts of the state that may cause memory-allocation errors.
** ('g->version' !== NULL flags that the state was completely build)
*/
const f_luaopen = function(L) {
    let g = L.l_G;
    stack_init(L, L);
    init_registry(L, g);
    ltm.luaT_init(L);
    g.version = lapi.lua_version(null);
};

const lua_newthread = function(L) {
    let g = L.l_G;
    let L1 = new lua_State(g);
    L.stack[L.top] = new lobject.TValue(CT.LUA_TTHREAD, L1);
    L.top++;
    assert(L.top <= L.ci.top, "stack overflow");
    L1.hookmask = L.hookmask;
    L1.basehookcount = L.basehookcount;
    L1.hook = L.hook;
    L1.hookcount = L1.basehookcount;
    stack_init(L1, L);
    return L1;
};

const luaE_freethread = function(L, L1) {
    lfunc.luaF_close(L1, L1.stack);
    freestack(L1);
};

const lua_newstate = function() {
    let g = new global_State();
    let L = new lua_State(g);
    g.mainthread = L;

    if (ldo.luaD_rawrunprotected(L, f_luaopen, null) !== TS.LUA_OK) {
        L = null;
    }

    return L;
};

const close_state = function(L) {
    lfunc.luaF_close(L, L.stack);  /* close all upvalues for this thread */
    freestack(L);
};

const lua_close = function(L) {
    L = L.l_G.mainthread;  /* only the main thread can be closed */
    close_state(L);
};

module.exports.lua_State       = lua_State;
module.exports.CallInfo        = CallInfo;
module.exports.CIST_OAH        = (1<<0);  /* original value of 'allowhook' */
module.exports.CIST_LUA        = (1<<1);  /* call is running a Lua function */
module.exports.CIST_HOOKED     = (1<<2);  /* call is running a debug hook */
module.exports.CIST_FRESH      = (1<<3);  /* call is running on a fresh invocation of luaV_execute */
module.exports.CIST_YPCALL     = (1<<4);  /* call is a yieldable protected call */
module.exports.CIST_TAIL       = (1<<5);  /* call was tail called */
module.exports.CIST_HOOKYIELD  = (1<<6);  /* last hook called yielded */
module.exports.CIST_LEQ        = (1<<7);  /* using __lt for __le */
module.exports.CIST_FIN        = (1<<8);   /* call is running a finalizer */
module.exports.EXTRA_STACK     = EXTRA_STACK;
module.exports.lua_close       = lua_close;
module.exports.lua_newstate    = lua_newstate;
module.exports.lua_newthread   = lua_newthread;
module.exports.luaE_extendCI   = luaE_extendCI;
module.exports.luaE_freeCI     = luaE_freeCI;
module.exports.luaE_freethread = luaE_freethread;
<commit_msg>src/lstate.js: Use api_incr_top instead of assert<commit_after>"use strict";

const defs                 = require('./defs.js');
const lobject              = require('./lobject.js');
const ldo                  = require('./ldo.js');
const lapi                 = require('./lapi.js');
const ltable               = require('./ltable.js');
const lfunc                = require('./lfunc.js');
const ltm                  = require('./ltm.js');
const CT                   = defs.constant_types;
const TS                   = defs.thread_status;
const LUA_NUMTAGS          = CT.LUA_NUMTAGS;

const EXTRA_STACK = 5;

const BASIC_STACK_SIZE = 2 * defs.LUA_MINSTACK;

class CallInfo {

    constructor() {
        this.func = null;
        this.funcOff = NaN;
        this.top = NaN;
        this.previous = null;
        this.next = null;

        /* only for Lua functions */
        this.l_base = NaN; /* base for this function */
        this.l_code = null; /* reference to this.func.p.code */
        this.l_savedpc = NaN; /* offset into l_code */
        /* only for JS functions */
        this.c_k = null;  /* continuation in case of yields */
        this.c_old_errfunc = null;
        this.c_ctx = null;  /* context info. in case of yields */

        this.nresults = NaN;
        this.callstatus = NaN;
    }

}

class lua_State {

    constructor(g) {
        this.id = g.id_counter++;

        this.base_ci = new CallInfo(); /* CallInfo for first level (C calling Lua) */
        this.top = NaN; /* first free slot in the stack */
        this.stack_last = NaN; /* last free slot in the stack */
        this.oldpc = NaN; /* last pc traced */

        /* preinit_thread */
        this.l_G = g;
        this.stack = null;
        this.ci = null;
        this.errorJmp = null;
        this.nCcalls = 0;
        this.hook = null;
        this.hookmask = 0;
        this.basehookcount = 0;
        this.allowhook = 1;
        this.hookcount = this.basehookcount;
        this.openupval = null;
        this.nny = 1;
        this.status = TS.LUA_OK;
        this.errfunc = 0;
    }

}

class global_State {

    constructor() {
        this.id_counter = 0; /* used to give objects unique ids */
        this.ids = new WeakMap();

        this.mainthread = null;
        this.l_registry = new lobject.TValue(CT.LUA_TNIL, null);
        this.panic = null;
        this.atnativeerror = null;
        this.version = null;
        this.tmname = new Array(ltm.TMS.TM_N);
        this.mt = new Array(LUA_NUMTAGS);
    }

}

const luaE_extendCI = function(L) {
    let ci = new CallInfo();
    L.ci.next = ci;
    ci.previous = L.ci;
    ci.next = null;
    L.ci = ci;
    return ci;
};

const luaE_freeCI = function(L) {
    let ci = L.ci;
    ci.next = null;
};

const stack_init = function(L1, L) {
    L1.stack = new Array(BASIC_STACK_SIZE);
    L1.top = 0;
    L1.stack_last = BASIC_STACK_SIZE - EXTRA_STACK;
    /* initialize first ci */
    let ci = L1.base_ci;
    ci.next = ci.previous = null;
    ci.callstatus = 0;
    ci.funcOff = L1.top;
    ci.func = L1.stack[L1.top];
    L1.stack[L1.top++] = new lobject.TValue(CT.LUA_TNIL, null);
    ci.top = L1.top + defs.LUA_MINSTACK;
    L1.ci = ci;
};

const freestack = function(L) {
    L.ci = L.base_ci;
    luaE_freeCI(L);
    L.stack = null;
};

/*
** Create registry table and its predefined values
*/
const init_registry = function(L, g) {
    let registry = ltable.luaH_new(L);
    g.l_registry.sethvalue(registry);
    ltable.luaH_setint(registry, defs.LUA_RIDX_MAINTHREAD, new lobject.TValue(CT.LUA_TTHREAD, L));
    ltable.luaH_setint(registry, defs.LUA_RIDX_GLOBALS, new lobject.TValue(CT.LUA_TTABLE, ltable.luaH_new(L)));
};

/*
** open parts of the state that may cause memory-allocation errors.
** ('g->version' !== NULL flags that the state was completely build)
*/
const f_luaopen = function(L) {
    let g = L.l_G;
    stack_init(L, L);
    init_registry(L, g);
    ltm.luaT_init(L);
    g.version = lapi.lua_version(null);
};

const lua_newthread = function(L) {
    let g = L.l_G;
    let L1 = new lua_State(g);
    L.stack[L.top] = new lobject.TValue(CT.LUA_TTHREAD, L1);
    lapi.api_incr_top(L);
    L1.hookmask = L.hookmask;
    L1.basehookcount = L.basehookcount;
    L1.hook = L.hook;
    L1.hookcount = L1.basehookcount;
    stack_init(L1, L);
    return L1;
};

const luaE_freethread = function(L, L1) {
    lfunc.luaF_close(L1, L1.stack);
    freestack(L1);
};

const lua_newstate = function() {
    let g = new global_State();
    let L = new lua_State(g);
    g.mainthread = L;

    if (ldo.luaD_rawrunprotected(L, f_luaopen, null) !== TS.LUA_OK) {
        L = null;
    }

    return L;
};

const close_state = function(L) {
    lfunc.luaF_close(L, L.stack);  /* close all upvalues for this thread */
    freestack(L);
};

const lua_close = function(L) {
    L = L.l_G.mainthread;  /* only the main thread can be closed */
    close_state(L);
};

module.exports.lua_State       = lua_State;
module.exports.CallInfo        = CallInfo;
module.exports.CIST_OAH        = (1<<0);  /* original value of 'allowhook' */
module.exports.CIST_LUA        = (1<<1);  /* call is running a Lua function */
module.exports.CIST_HOOKED     = (1<<2);  /* call is running a debug hook */
module.exports.CIST_FRESH      = (1<<3);  /* call is running on a fresh invocation of luaV_execute */
module.exports.CIST_YPCALL     = (1<<4);  /* call is a yieldable protected call */
module.exports.CIST_TAIL       = (1<<5);  /* call was tail called */
module.exports.CIST_HOOKYIELD  = (1<<6);  /* last hook called yielded */
module.exports.CIST_LEQ        = (1<<7);  /* using __lt for __le */
module.exports.CIST_FIN        = (1<<8);   /* call is running a finalizer */
module.exports.EXTRA_STACK     = EXTRA_STACK;
module.exports.lua_close       = lua_close;
module.exports.lua_newstate    = lua_newstate;
module.exports.lua_newthread   = lua_newthread;
module.exports.luaE_extendCI   = luaE_extendCI;
module.exports.luaE_freeCI     = luaE_freeCI;
module.exports.luaE_freethread = luaE_freethread;
<|endoftext|>


<commit_before>//The start of the urls for api calls.
var staticUrl = 'https://global.api.pvp.net/api/lol/static-data/na/v1.2';
var naUrl = 'https://na.api.pvp.net/api/lol/na/v1.4';

function getRunes(runePage, key) {
  //clear any previous runepage
  $('#stats').html('');
  $('#totals').html('');
  //get static rune data
  $.get(staticUrl + '/rune?api_key=' + key, function(runes) {
    //Stores and adds numerical value of like rune stats
    var statAccum = {};
    //Stores used rune descriptions
    var descripions = {};
    for(var i = 0; i < runePage.slots.length; i++) {
      //gets the numerical value of the rune.
      var numStat = runes.data[runePage.slots[i].runeId].description.match(/(\d+\.?\d*)(.*)/)[1];
      //gets the type of stat
      var textStat = runes.data[runePage.slots[i].runeId].description.match(/(\d+\.?\d*)(.*)/)[2];
      var desc = runes.data[runePage.slots[i].runeId].description;
      //Combine stat values to give total stats gained at lvl1
      if(!(textStat in statAccum)) {
        statAccum[textStat] = parseFloat(numStat);
      }
      else
        statAccum[textStat] += parseFloat(numStat);
      //Only want to display one entry per unique rune
      if(!(desc in descripions)) {
        descripions[desc] = 1;
      }
      else
        descripions[desc]++;
    }
    //dump unique runes and their totals
    $.each(descripions, function(key, value) {
        $('#stats').append(value + 'x ' + key + '
');
      });
    //dump stat totals
    $('#totals').append('Stat totals at level 1 (level 18)
');
    $.each(statAccum, function(key, value) {
      //Modify per level stats to display total recieved at level 18
      if(key.indexOf('per level') !== -1)
        value += ' (' + (18 * value) + ')';
      $('#totals').append(key + ': ' + value + '
');
    });
  });
}

function getPage() {
  var summoner = $('#summonerName').val();
  var key = $('#key').val();
  //Can't use as object when spaces are included.
  summoner = summoner.replace(/ /g , '');
  var getIdUrl = naUrl + '/summoner/by-name/' + summoner + '?api_key=' + key;
  var getCurrentPageUrl;
  var sumId;
  console.log(summoner);
  $.get(getIdUrl, function(data) {
    //get summoner id for next api calls
    sumId = data[summoner].id;
    console.log(sumId);
    getCurrentPageUrl = naUrl + '/summoner/' + sumId + '/runes?api_key=' + key;
    $.get(getCurrentPageUrl, function(data) {
      //gets all rune pages for the summoner
      var runePages = data[sumId].pages;
      for(var i = 0; i < runePages.length; i++) {
        //get current/last used runepage
        if(runePages[i].current === true) {
          $('#name').html(runePages[i].name);
          getRunes(runePages[i], key);
        }
      }
    });
  });
}<commit_msg>Consolidated all per level stats into one entry.<commit_after>//The start of the urls for api calls.
var staticUrl = 'https://global.api.pvp.net/api/lol/static-data/na/v1.2';
var naUrl = 'https://na.api.pvp.net/api/lol/na/v1.4';

function getRunes(runePage, key) {
  //clear any previous runepage
  $('#stats').html('');
  $('#totals').html('');
  //get static rune data
  $.get(staticUrl + '/rune?api_key=' + key, function(runes) {
    //Stores and adds numerical value of like rune stats
    var statAccum = {};
    //Stores used rune descriptions
    var descripions = {};
    for(var i = 0; i < runePage.slots.length; i++) {
      //gets the numerical value of the rune.
      var numStat = runes.data[runePage.slots[i].runeId].description.match(/(\d+\.?\d*)(.*)/)[1];
      //gets the type of stat
      var textStat = runes.data[runePage.slots[i].runeId].description.match(/(\d+\.?\d*)(.*)/)[2];
      var desc = runes.data[runePage.slots[i].runeId].description;

      if(textStat.indexOf('(') !== -1) {
        textStat = textStat.substr(0, textStat.indexOf('('));
      }
      //Combine stat values to give total stats gained at lvl1
      if(!(textStat in statAccum)) {
        statAccum[textStat] = parseFloat(numStat);
      }
      else
        statAccum[textStat] += parseFloat(numStat);
      //Only want to display one entry per unique rune
      if(!(desc in descripions)) {
        descripions[desc] = 1;
      }
      else
        descripions[desc]++;
    }
    //dump unique runes and their totals
    $.each(descripions, function(key, value) {
        $('#stats').append(value + 'x ' + key + '
');
      });
    //dump stat totals
    $('#totals').append('Stat totals at level 1 (level 18)
');
    $.each(statAccum, function(key, value) {
      //Modify per level stats to display total recieved at level 18
      if(key.indexOf('per level') !== -1)
        value += ' (' + (18 * value) + ')';
      $('#totals').append(key + ': ' + value + '
');
    });
  });
}

function getPage() {
  var summoner = $('#summonerName').val();
  var key = $('#key').val();
  //Can't use as object when spaces are included.
  summoner = summoner.replace(/ /g , '');
  var getIdUrl = naUrl + '/summoner/by-name/' + summoner + '?api_key=' + key;
  var getCurrentPageUrl;
  var sumId;
  console.log(summoner);
  $.get(getIdUrl, function(data) {
    //get summoner id for next api calls
    sumId = data[summoner].id;
    console.log(sumId);
    getCurrentPageUrl = naUrl + '/summoner/' + sumId + '/runes?api_key=' + key;
    $.get(getCurrentPageUrl, function(data) {
      //gets all rune pages for the summoner
      var runePages = data[sumId].pages;
      for(var i = 0; i < runePages.length; i++) {
        //get current/last used runepage
        if(runePages[i].current === true) {
          $('#name').html(runePages[i].name);
          getRunes(runePages[i], key);
        }
      }
    });
  });
}<|endoftext|>


<commit_before>var chai = require('chai');
var should = chai.should();
var expect = chai.expect;
var nock = require('nock');

var chat = require('./chat');
var errors = require('../errors');
var Cache = require('../cache');
var slackTypes = require('./types');

describe('chat', function () {

    before(function () {
        var cache = Cache;
        cache.data = {};
        cache.data.user = {};
        cache.data.user.name = 'bot';
        cache.data.users = [{ id: 'U0A1B2C3D4', name: 'phillip' }];
        cache.data.ims = {}
        cache.data.ims = [{ id: 'D0BN0UDLG',
                            is_im: true,
                            user: 'U0A1B2C3D4'}]
        cache.data.hostname = 'slack.com';

    });

    // function (method, params, callback)
    describe('#deleteMessage', function () {

        before(function () {

            var slackResponse = {
                ok: true,
                channel: 'C0BCBJYTS',
                ts: '1445172744.000006'
                }

            var scope = nock('https://slack.com')
                .post('/api/chat.delete')
                .reply(200, slackResponse);
        });

        it('exists as method on chat', function (done) {
            expect(typeof chat.deleteMessage).to.equal('function');
            done();
        })

        it('should return an error to callback if missing required arguments', function (done) {
            chat.deleteMessage(null, null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an api response', function (done) {
            chat.deleteMessage('string', 'string', function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                expect(result.ts).to.equal('1445172744.000006');
                done();
            });
        });
    });

    // function (method, params, callback)
    describe('#postMessage', function () {

        before(function () {

            var scope = nock('https://slack.com')
                .post('/api/chat.postMessage')
                .reply(200, {
                    ok: true
                });
        });

        it('exists as method on chat', function (done) {
            expect(typeof chat.postMessage).to.equal('function');
            done();
        })

        it('should return an error to callback if missing required arguments', function (done) {
            chat.postMessage(null, null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an api response', function (done) {
            chat.postMessage('general', 'message', function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                done();
            });

        });
    });

    // function (method, params, callback)
    describe('#postDirectMessage', function () {

        beforeEach(function () {

            var scope = nock('https://slack.com')
                .post('/api/chat.postMessage')
                .reply(200, {
                    ok: true,
                });
        });

        it('exists as method on chat', function (done) {
            expect(typeof chat.postDirectMessage).to.equal('function');
            done();
        })

        it('should return an error to callback if missing required arguments', function (done) {
            chat.postDirectMessage(null, null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an error if invalid user', function (done) {
            chat.postDirectMessage('phillips', 'message', function (err, result) {
                expect(err).to.be.an('error');
                expect(err.message).to.equal('the channel, group, or user could not be found');

            });
             done();
        });

        it('should return an api response', function (done) {
            chat.postDirectMessage('phillip', 'message', function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                done();
            });

        });
    });

    // function (method, params, callback)
    describe('#updateMessage', function () {

        before(function () {

            var scope = nock('https://slack.com')
                .post('/api/chat.delete')
                .reply(200, {
                    ok: true
                });
        });

        it('exists as method on chat', function (done) {
            expect(typeof chat.updateMessage).to.equal('function');
            done();
        })

        it('should return an error to callback if missing required arguments', function (done) {
            chat.updateMessage(null, null,null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        // it('should return an api response', function (done) {
        //     chat.postMessage('general', 'message', function (err, result) {
        //         expect(result).to.be.an('object');
        //         expect(result.ok).to.equal(true);
        //         done();
        //     });

        // });
    });
    after(function () {
        cache = null;
    });
});<commit_msg>Added chat.updateMessage test<commit_after>var chai = require('chai');
var should = chai.should();
var expect = chai.expect;
var nock = require('nock');

var chat = require('./chat');
var errors = require('../errors');
var Cache = require('../cache');
var slackTypes = require('./types');

describe('chat', function () {

    before(function () {
        var cache = Cache;
        cache.data = {};
        cache.data.user = {};
        cache.data.user.name = 'bot';
        cache.data.users = [{ id: 'U0A1B2C3D4', name: 'phillip' }];
        cache.data.ims = {}
        cache.data.ims = [{ id: 'D0BN0UDLG',
                            is_im: true,
                            user: 'U0A1B2C3D4'}]
        cache.data.hostname = 'slack.com';

    });

    // function (method, params, callback)
    describe('#deleteMessage', function () {

        before(function () {

            var slackResponse = {
                ok: true,
                channel: 'C0BCBJYTS',
                ts: '1445172744.000006'
                }

            var scope = nock('https://slack.com')
                .post('/api/chat.delete')
                .reply(200, slackResponse);
        });

        it('exists as method on chat', function (done) {
            expect(typeof chat.deleteMessage).to.equal('function');
            done();
        })

        it('should return an error to callback if missing required arguments', function (done) {
            chat.deleteMessage(null, null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an api response', function (done) {
            chat.deleteMessage('string', 'string', function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                expect(result.ts).to.equal('1445172744.000006');
                done();
            });
        });
    });

    // function (method, params, callback)
    describe('#postMessage', function () {

        before(function () {

            var scope = nock('https://slack.com')
                .post('/api/chat.postMessage')
                .reply(200, {
                    ok: true
                });
        });

        it('exists as method on chat', function (done) {
            expect(typeof chat.postMessage).to.equal('function');
            done();
        })

        it('should return an error to callback if missing required arguments', function (done) {
            chat.postMessage(null, null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an api response', function (done) {
            chat.postMessage('general', 'message', function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                done();
            });

        });
    });

    // function (method, params, callback)
    describe('#postDirectMessage', function () {

        beforeEach(function () {

            var scope = nock('https://slack.com')
                .post('/api/chat.postMessage')
                .reply(200, {
                    ok: true,
                });
        });

        it('exists as method on chat', function (done) {
            expect(typeof chat.postDirectMessage).to.equal('function');
            done();
        })

        it('should return an error to callback if missing required arguments', function (done) {
            chat.postDirectMessage(null, null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an error if invalid user', function (done) {
            chat.postDirectMessage('phillips', 'message', function (err, result) {
                expect(err).to.be.an('error');
                expect(err.message).to.equal('the channel, group, or user could not be found');

            });
             done();
        });

        it('should return an api response', function (done) {
            chat.postDirectMessage('phillip', 'message', function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                done();
            });

        });
    });

    // function (method, params, callback)
    describe('#updateMessage', function () {

        beforeEach(function () {

            var slackResponse = { ok: true,
                channel: 'C0BCBJYTS',
                ts: '1445389812.000011',
                text: 'Message text',
                message:
                { type: 'message',
                  user: 'U0BN3JFH7',
                  text: 'Edited message text',
                edited: { user: 'U0BN3JFH7', ts: '1445390152.000000'}}};

            var scope = nock('https://slack.com')
                .post('/api/chat.update')
                .reply(200, slackResponse);
        });

        it('exists as method on chat', function (done) {
            expect(typeof chat.updateMessage).to.equal('function');
            done();
        })

        it('should return an error to callback if missing required arguments', function (done) {
            chat.updateMessage(null, null,null, function (err, result) {
                expect(err).to.not.equal(null);
                expect(err.message).to.equal('must supply valid argument(s)');
            });
            done();
        });

        it('should return an api response', function (done) {
            chat.updateMessage('string', 'string', 'string', function (err, result) {
                expect(result).to.be.an('object');
                expect(result.ok).to.equal(true);
                expect(result.message.edited.ts).to.equal('1445390152.000000');
                done();
            });
        });
    });
    after(function () {
        cache = null;
    });
});<|endoftext|>


<commit_before>/*
 * Licensed to Cloudkick, Inc ('Cloudkick') under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * Cloudkick licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

var util = require('util');
var path = require('path');

var sprintf = require('sprintf').sprintf;

var TestReporter = require('./base').TestReporter;
var testUtil = require('./../../util');

function CliReporter(tests, options) {
  TestReporter.call(this, tests, options);

  this._dateStart = null;
  this._dateEnd = null;
  this._successes = 0;
  this._failures = 0;
  this._timeouts = 0;
}

util.inherits(CliReporter, TestReporter);

CliReporter.prototype.handleTestsStart = function() {
  this._dateStart = testUtil.getUnixTimestamp();
};

CliReporter.prototype.handleTestFileStart = function(filePath) {
  console.log(filePath);
};

CliReporter.prototype.handleTestFileComplete = function(filePath, stdout, stderr) {
  var tests, test, key;

  stdout = stdout || '';
  stderr = stderr || '';
  tests = this._testResults[filePath];

  for (key in tests) {
    if (tests.hasOwnProperty(key)) {
      test = tests[key];

      if (test.error) {
        this._failures++;
        this._reportFailure(test.name, test.error);
      }
      else if (test.timeout) {
        this._timeouts++;
        this._reportTimeout();
      }
      else {
        this._successes++;
        this._reportSuccess(test.name);
      }
    }
  }

  if (this._failures > 0 || this._timeouts > 0) {
    this._printStderr(stderr);
    this._printStdout(stdout);
  }
  else {
    if (this._options['print_stderr']) {
      this._printStderr(stderr);
    }

    if (this._options['print_stdout']) {
      this._printStdout(stdout);
    }
  }
};

CliReporter.prototype.handleTestsComplete = function() {
  this._dateEnd = testUtil.getUnixTimestamp();
  this._reportStatistics();

  return (this._failures + this._timeouts);
};

CliReporter.prototype._printStdout = function(stdout) {
  if (stdout.length > 0) {
    console.log('');
    console.log('\033[1mStdout\033[22m:');
    console.log(stdout);
  }
};

CliReporter.prototype._printStderr = function(stdout) {
  if (stdout.length > 0) {
    console.log('');
    console.log('\033[1mStderr\033[22m:');
    console.log(stdout);
  }
};

CliReporter.prototype._reportSuccess = function(testName) {
  console.log(sprintf('  %s \033[1;32m[OK]\033[0m',
                      testUtil.addCharacters(testName, 74, ' ')));
};

CliReporter.prototype._reportFailure = function(testName, error) {
  var errMsg = (error.stack) ? error.stack : error.message;
  console.log(sprintf('  %s \033[1;31m[FAIL]\033[0m',
                      testUtil.addCharacters(testName, 72, ' ')));
  console.log('');
  console.log('\033[1mException\033[22m:');
  console.log(errMsg);
  console.log('');
};

CliReporter.prototype._reportTimeout = function() {
  console.log(sprintf('  %s \033[1;36m[TIMEOUT]\033[0m',
                      testUtil.addCharacters('timeout', 69, ' ')));
};

CliReporter.prototype._reportStatistics = function() {
  var runTime = (this._dateEnd - this._dateStart);
  var successes = this._successes;
  var failures = this._failures;
  var timeouts = this._timeouts;

  console.log(testUtil.addCharacters('', 81, '-'));
  console.log(sprintf('Ran %d tests in %0.3fs', (successes + failures), runTime));
  console.log('');
  console.log(sprintf('Successes: %s', successes));
  console.log(sprintf('Failures: %s', failures));
  console.log(sprintf('Timeouts: %s', timeouts));
  console.log('');

  if (failures === 0 && timeouts === 0) {
    console.log('\033[1;32mPASSED\033[0m');
  }
  else {
    console.log('\033[1;31mFAILED\033[0m');
  }
};

exports.name = 'cli';
exports.klass = CliReporter;
<commit_msg>Use terminal module for output stuff in the test reporter.<commit_after>/*
 * Licensed to Cloudkick, Inc ('Cloudkick') under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * Cloudkick licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

var util = require('util');
var path = require('path');

var sprintf = require('sprintf').sprintf;
var terminal = require('terminal');

var TestReporter = require('./base').TestReporter;
var testUtil = require('./../../util');

function CliReporter(tests, options) {
  TestReporter.call(this, tests, options);

  this._dateStart = null;
  this._dateEnd = null;
  this._successes = 0;
  this._failures = 0;
  this._timeouts = 0;

  this._puts = (this._options['styles']) ? terminal.puts : terminal.putsNoStyle;
}

util.inherits(CliReporter, TestReporter);

CliReporter.prototype.handleTestsStart = function() {
  this._dateStart = testUtil.getUnixTimestamp();
};

CliReporter.prototype.handleTestFileStart = function(filePath) {
  this._puts(filePath);
};

CliReporter.prototype.handleTestFileComplete = function(filePath, stdout, stderr) {
  var tests, test, key;

  stdout = stdout || '';
  stderr = stderr || '';
  tests = this._testResults[filePath];

  for (key in tests) {
    if (tests.hasOwnProperty(key)) {
      test = tests[key];

      if (test.error) {
        this._failures++;
        this._reportFailure(test.name, test.error);
      }
      else if (test.timeout) {
        this._timeouts++;
        this._reportTimeout();
      }
      else {
        this._successes++;
        this._reportSuccess(test.name);
      }
    }
  }

  if (this._failures > 0 || this._timeouts > 0) {
    this._printStderr(stderr);
    this._printStdout(stdout);
  }
  else {
    if (this._options['print_stderr']) {
      this._printStderr(stderr);
    }

    if (this._options['print_stdout']) {
      this._printStdout(stdout);
    }
  }
};

CliReporter.prototype.handleTestsComplete = function() {
  this._dateEnd = testUtil.getUnixTimestamp();
  this._reportStatistics();

  return (this._failures + this._timeouts);
};

CliReporter.prototype._printStdout = function(stdout) {
  if (stdout.length > 0) {
    this._puts('');
    this._puts('[bold]Stdout[bold]:');
    this._puts(stdout);
  }
};

CliReporter.prototype._printStderr = function(stdout) {
  if (stdout.length > 0) {
    this._puts('');
    this._puts('[bold]Stderr[bold]:');
    this._puts(stdout);
  }
};

CliReporter.prototype._reportSuccess = function(testName) {
  this._puts(sprintf('  %s [green][OK][/green]',
                      testUtil.addCharacters(testName, 74, ' ')));
};

CliReporter.prototype._reportFailure = function(testName, error) {
  var errMsg = (error.stack) ? error.stack : error.message;
  this._puts(sprintf('  %s [red][FAIL][/red]',
                      testUtil.addCharacters(testName, 72, ' ')));
  this._puts('');
  this._puts('[bold]Exception[/bold]');
  this._puts(errMsg);
  this._puts('');
};

CliReporter.prototype._reportTimeout = function() {
  this._puts(sprintf('  %s [cyan][TIMEOUT][/cyan]',
                      testUtil.addCharacters('timeout', 69, ' ')));
};

CliReporter.prototype._reportStatistics = function() {
  var runTime = (this._dateEnd - this._dateStart);
  var successes = this._successes;
  var failures = this._failures;
  var timeouts = this._timeouts;

  this._puts(testUtil.addCharacters('', 81, '-'));
  this._puts(sprintf('Ran %d tests in %0.3fs', (successes + failures), runTime));
  this._puts('');
  this._puts(sprintf('Successes: %s', successes));
  this._puts(sprintf('Failures: %s', failures));
  this._puts(sprintf('Timeouts: %s', timeouts));
  this._puts('');

  if (failures === 0 && timeouts === 0) {
    this._puts('[green]PASSED[/green]');
  }
  else {
    this._puts('[red]FAILED[/red]');
  }
};

exports.name = 'cli';
exports.klass = CliReporter;
<|endoftext|>


<commit_before>"use strict";

/*
 * Screenshow Twitter module
 * Author: Tuomas Virtanen
 */

function ScreenTwitter(jmobj, obj) {
    this.obj = obj;
    this.jmobj = jmobj;
    this.cache = [];

    this.init = function() {
        this.obj.on('enterStep', $.proxy(this.render, this));
    }

    this.render = function() {
        var out = '';
        $.each(this.cache, function(i, k) {
            out += '
';
            out += '@'+k.author+': ';
            out += ''+k.text+'
';
            out += '» '+k.time+'';
            out += '
';
        });
        this.obj.html(out);
    }

    this.handleTweets = function(tweets, options) {
        // Parse tweets
        var r = [];
        $.each(tweets, function(i, k) {
            r.push({
                author: k.user.screen_name,
                text: twitterlib.ify.clean(twitterlib.expandLinks(k)),
                time: twitterlib.time.relative(k.created_at),
                tid: k.id_str,
                publishedDate: k.created_at
            });
        });
        this.cache = r;

        // Check if we want to show the irc slide
        this.obj.data("stepData").exclude = (this.cache.length == 0);
        this.jmobj.jmpress('reapply', this.obj);
    }

    this.update = function() {
        twitterlib.timeline('Instanssi', { page: 1, limit: 5 }, $.proxy(this.handleTweets, this));
    }
}
<commit_msg>screenshow: Rename twitter message field class.<commit_after>"use strict";

/*
 * Screenshow Twitter module
 * Author: Tuomas Virtanen
 */

function ScreenTwitter(jmobj, obj) {
    this.obj = obj;
    this.jmobj = jmobj;
    this.cache = [];

    this.init = function() {
        this.obj.on('enterStep', $.proxy(this.render, this));
    }

    this.render = function() {
        var out = '';
        $.each(this.cache, function(i, k) {
            out += '
';
            out += '@'+k.author+': ';
            out += ''+k.text+'
';
            out += '» '+k.time+'';
            out += '
';
        });
        this.obj.html(out);
    }

    this.handleTweets = function(tweets, options) {
        // Parse tweets
        var r = [];
        $.each(tweets, function(i, k) {
            r.push({
                author: k.user.screen_name,
                text: twitterlib.ify.clean(twitterlib.expandLinks(k)),
                time: twitterlib.time.relative(k.created_at),
                tid: k.id_str,
                publishedDate: k.created_at
            });
        });
        this.cache = r;

        // Check if we want to show the irc slide
        this.obj.data("stepData").exclude = (this.cache.length == 0);
        this.jmobj.jmpress('reapply', this.obj);
    }

    this.update = function() {
        twitterlib.timeline('Instanssi', { page: 1, limit: 5 }, $.proxy(this.handleTweets, this));
    }
}
<|endoftext|>


<commit_before>var cached_term = "";
var cached_matches = [];
var cached_index;
var cached_table = $('table.focused_table');

function get_zid_as_int(object) {
    return parseInt(object.attr("zid"), 10);
}

function match_on_visible_text(row, search_term) {
    // You can't select on :visible, since that includes hidden elements that
    // take up space.
    if (row.find(".message_content, .sender_name, .message_header")
           .text().toLowerCase().indexOf(search_term) !== -1) {
        return true;
    }
    return false;
}

function search(term, highlighted_message, reverse) {
    // term: case-insensitive text to search for
    // highlighted_message: the current location of the pointer. Ignored
    //     on cached queries
    // reverse: boolean as to whether the search is forward or backwards
    //
    // returns a message object containing the search term.
    var previous_header_matched = false;

    var focused_table = $('table.focused_table');
    if ((term !== cached_term) || (cached_table[0] !== focused_table[0])) {
        cached_term = term;
        cached_matches = [];
        cached_index = null;
        cached_table = focused_table;
        var selected_zid = get_zid_as_int(highlighted_message);

        focused_table.find('.message_row, .recipient_row').each(function (index, row) {
            row = $(row);
            if (previous_header_matched || (match_on_visible_text(row, term))) {
                previous_header_matched = false;

                if (row.hasClass("recipient_row")) {
                    previous_header_matched = true;
                } else {
                    cached_matches.push(row);
                    var zid = get_zid_as_int(row);
                    if ((reverse && (zid <= selected_zid)) ||
                        (!reverse && (zid >= selected_zid) && !cached_index)) {
                        // Keep track of the closest match going up or down.
                        cached_index = cached_matches.length - 1;
                    }
                }
            }
        });

        return cached_matches[cached_index];
    }

    if (reverse) {
        if (cached_index > 0) {
            cached_index--;
        }
    } else {
        if (cached_index < cached_matches.length - 1) {
            cached_index++;
        }
    }

    return cached_matches[cached_index];
}

function highlight_match(row, search_term) {
    $('table tr').removeHighlight();
    row.highlight(search_term);

    row = row.prev('.recipient_row');
    if ((row.length !== 0) && (match_on_visible_text(row, search_term))) {
        row.highlight(search_term);
    }
}

function search_button_handler(reverse) {
    var query = $('#search').val().toLowerCase();
    var res = search(query, selected_message, reverse);
    if (!res) {
        return;
    }

    select_message_by_id(res.attr("zid"));
    highlight_match(res, query);
    scroll_to_selected();
}

function clear_search_cache() {
    cached_term = "";
}

function clear_search() {
    $('table tr').removeHighlight();
    $('#search').val('').focus();
    clear_search_cache();
}

function something_is_highlighted() {
    return $(".highlight").length > 0;
}

function update_highlight_on_narrow() {
    highlight_match(selected_message, cached_term);
    clear_search_cache();
}
<commit_msg>match_on_visible_text: Return boolean directly, without a conditional<commit_after>var cached_term = "";
var cached_matches = [];
var cached_index;
var cached_table = $('table.focused_table');

function get_zid_as_int(object) {
    return parseInt(object.attr("zid"), 10);
}

function match_on_visible_text(row, search_term) {
    // You can't select on :visible, since that includes hidden elements that
    // take up space.
    return row.find(".message_content, .sender_name, .message_header")
              .text().toLowerCase().indexOf(search_term) !== -1;
}

function search(term, highlighted_message, reverse) {
    // term: case-insensitive text to search for
    // highlighted_message: the current location of the pointer. Ignored
    //     on cached queries
    // reverse: boolean as to whether the search is forward or backwards
    //
    // returns a message object containing the search term.
    var previous_header_matched = false;

    var focused_table = $('table.focused_table');
    if ((term !== cached_term) || (cached_table[0] !== focused_table[0])) {
        cached_term = term;
        cached_matches = [];
        cached_index = null;
        cached_table = focused_table;
        var selected_zid = get_zid_as_int(highlighted_message);

        focused_table.find('.message_row, .recipient_row').each(function (index, row) {
            row = $(row);
            if (previous_header_matched || (match_on_visible_text(row, term))) {
                previous_header_matched = false;

                if (row.hasClass("recipient_row")) {
                    previous_header_matched = true;
                } else {
                    cached_matches.push(row);
                    var zid = get_zid_as_int(row);
                    if ((reverse && (zid <= selected_zid)) ||
                        (!reverse && (zid >= selected_zid) && !cached_index)) {
                        // Keep track of the closest match going up or down.
                        cached_index = cached_matches.length - 1;
                    }
                }
            }
        });

        return cached_matches[cached_index];
    }

    if (reverse) {
        if (cached_index > 0) {
            cached_index--;
        }
    } else {
        if (cached_index < cached_matches.length - 1) {
            cached_index++;
        }
    }

    return cached_matches[cached_index];
}

function highlight_match(row, search_term) {
    $('table tr').removeHighlight();
    row.highlight(search_term);

    row = row.prev('.recipient_row');
    if ((row.length !== 0) && (match_on_visible_text(row, search_term))) {
        row.highlight(search_term);
    }
}

function search_button_handler(reverse) {
    var query = $('#search').val().toLowerCase();
    var res = search(query, selected_message, reverse);
    if (!res) {
        return;
    }

    select_message_by_id(res.attr("zid"));
    highlight_match(res, query);
    scroll_to_selected();
}

function clear_search_cache() {
    cached_term = "";
}

function clear_search() {
    $('table tr').removeHighlight();
    $('#search').val('').focus();
    clear_search_cache();
}

function something_is_highlighted() {
    return $(".highlight").length > 0;
}

function update_highlight_on_narrow() {
    highlight_match(selected_message, cached_term);
    clear_search_cache();
}
<|endoftext|>