<commit_before>/**
 * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 * WSO2 Inc. 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.
 */
define(['require', 'lodash', 'log', 'jquery', 'backbone', 'command', 'sample_preview', 'workspace/file'],
    function (require, _, log, $, Backbone, CommandManager, SamplePreviewView, File) {

        var FirstLaunchWelcomePage = Backbone.View.extend({
            initialize: function (options) {
                var errMsg;
                if (!_.has(options, 'tab')) {
                    errMsg = 'unable to find a reference for editor tab';
                    log.error(errMsg);
                    throw errMsg;
                }
                    this._tab = _.get(options, 'tab');
                var container = $(this._tab.getContentContainer());
                // make sure default tab content are cleared
                container.empty();
                // check whether container element exists in dom
                if (!container.length > 0) {
                    errMsg = 'unable to find container for welcome screen with selector: ' +
                        _.get(options, 'container');
                    log.error(errMsg);
                    throw errMsg;
                }
                this.app = options.application;
                this._$parent_el = container;
                this._options = options;
            },

            hide: function(){
                //Hiding menu bar
                this._options.application.menuBar.show();
                this.$el.hide();
            },

            show: function(){
                //Hiding menu bar
                this._options.application.menuBar.hide();
                this.$el.show();
            },

            render: function () {
                var self = this;
                var backgroundDiv = $('

');
                var mainWelcomeDiv = $('

');
                var leftPane = $('

');
                var buttonWrap = $('

');
                var productNameWrap = $('

');
                var newButton = $('<button></button>');
                var openButton = $('<button></button>');

                var contentPane = $('

');
                var recentFilesPane = $('

');
                var samplesPane = $('

');
                var quickLinksPane = $('

');

                backgroundDiv.addClass(_.get(this._options, 'cssClass.parent'));
                mainWelcomeDiv.addClass(_.get(this._options, 'cssClass.outer'));
                leftPane.addClass(_.get(this._options, 'cssClass.leftPane'));
                buttonWrap.addClass(_.get(this._options, 'cssClass.buttonWrap'));
                productNameWrap.addClass(_.get(this._options, 'cssClass.productNameWrap'));
                newButton.addClass(_.get(this._options, 'cssClass.buttonNew'));
                openButton.addClass(_.get(this._options, 'cssClass.buttonOpen'));
                contentPane.addClass(_.get(this._options, 'cssClass.contentPane'));
                recentFilesPane.addClass(_.get(this._options, 'cssClass.recentFilesPane'));
                samplesPane.addClass(_.get(this._options, 'cssClass.samplesPane'));
                quickLinksPane.addClass(_.get(this._options, 'cssClass.quickLinksPane'));

                newButton.text("New");
                openButton.text("Open");
                buttonWrap.append(newButton);
                buttonWrap.append(openButton);

                var productNameWrapHeader = $('
' +
                    '
Stream Processor Studio

');
                productNameWrap.append(productNameWrapHeader);

                leftPane.append(buttonWrap);
                leftPane.append(productNameWrap);

                mainWelcomeDiv.append(leftPane);

                var recentFilesHeader = $('
Recently opened
');
                recentFilesPane.append(recentFilesHeader);

                var samplesHeader = $('
Try out samples
');
                samplesPane.append(samplesHeader)
                var bodyUlSampleContent = $('

');
                var moreSampleLink = $('' +
                    'More Samples');
                bodyUlSampleContent.attr('id', "sampleContent");
                samplesPane.append(bodyUlSampleContent);
                samplesPane.append(moreSampleLink);

                // Show the import file dialog when "More Samples" is clicked.
                $(moreSampleLink).click(function(){
                    command.dispatch("open-sample-file-open-dialog");
                });

                var quickLinkHeader = $('
Quick links
');
                quickLinksPane.append(quickLinkHeader);

                var bodyUlQuickLinkContent = $('
' +
                    '
Quick Start Guide
' +
                    '
Siddhi Grammar
' +
                    '
Q&A
' +
                    '
Tutorials
' +
                    '
Documentation
' +
                    '
Support

');

                quickLinksPane.append(bodyUlQuickLinkContent);
                contentPane.append(samplesPane);
                contentPane.append(quickLinksPane);

                mainWelcomeDiv.append(contentPane);
                backgroundDiv.append(mainWelcomeDiv);

                this._$parent_el.append(backgroundDiv);
                this.$el = backgroundDiv;

                var command = this._options.application.commandManager;
                var browserStorage = this._options.application.browserStorage;

                var samples = _.get(this._options, "samples", []);

                var config;
                var samplePreview;

                var self = this;
                var workspaceServiceURL = self.app.config.services.workspace.endpoint;
                var sampleServiceURL = workspaceServiceURL + "/read/sample";

                for (var i = 0; i < samples.length; i++) {

                    var payload = samples[i];

                    $.ajax({
                        type: "POST",
                        contentType: "text/plain; charset=utf-8",
                        url: sampleServiceURL,
                        data: payload,
                        async: false,
                        success: function(data, textStatus, xhr) {
                            var config =
                                {
                                    "sampleName": samples[i].replace(/^.*[\\\/]/, '').match(/[^.]*/i)[0],
                                    "content":data.content,
                                    "parentContainer": "#sampleContent",
                                    "firstItem": i === 0,
                                    "clickEventCallback": function (event) {
                                        event.preventDefault();
                                        var file = new File({
                                            content: data.content
                                            },{
                                            storage: browserStorage
                                        });
                                        self.app.commandManager.dispatch("create-new-tab", {tabOptions: {file: file}});
                                        browserStorage.put("pref:passedFirstLaunch", true);
                                    }
                                };
                            samplePreview = new SamplePreviewView(config);
                            samplePreview.render();
                        },
                        error: function() {
                            alertError("Unable to read a sample file.");
                            throw "Unable to read a sample file.";
                        }
                    });
                }

                var workExPath = 'workspace';
                command.dispatch("open-folder", workExPath);

                var command = this._options.application.commandManager;
                var browserStorage = this._options.application.browserStorage;

                // When "new" is clicked, open up an empty workspace.
                $(newButton).on('click', function () {
                    command.dispatch("create-new-tab");
                    browserStorage.put("pref:passedFirstLaunch", true);
                });

                // Show the open file dialog when "open" is clicked.
                $(openButton).click(function(){
                    command.dispatch("open-file-open-dialog");
                    browserStorage.put("pref:passedFirstLaunch", true);
                });

                // upon welcome tab remove, set flag to indicate first launch pass
                this._tab.on('removed', function(){
                    browserStorage.put("pref:passedFirstLaunch", true);
                });

                function alertError(errorMessage) {
                    var errorNotification = getErrorNotification(errorMessage);
                    $("#notification-container").append(errorNotification);
                    errorNotification.fadeTo(2000, 200).slideUp(1000, function () {
                        errorNotification.slideUp(1000);
                    });
                }

                function getErrorNotification(errorMessage) {
                    return $(
                        "
" +
                        "" +
                        errorMessage +
                        "" +
                        "
");
                };
            }
        });

        return FirstLaunchWelcomePage;

    });

<commit_msg>Point docs to 420 space<commit_after>/**
 * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 * WSO2 Inc. 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.
 */
define(['require', 'lodash', 'log', 'jquery', 'backbone', 'command', 'sample_preview', 'workspace/file'],
    function (require, _, log, $, Backbone, CommandManager, SamplePreviewView, File) {

        var FirstLaunchWelcomePage = Backbone.View.extend({
            initialize: function (options) {
                var errMsg;
                if (!_.has(options, 'tab')) {
                    errMsg = 'unable to find a reference for editor tab';
                    log.error(errMsg);
                    throw errMsg;
                }
                    this._tab = _.get(options, 'tab');
                var container = $(this._tab.getContentContainer());
                // make sure default tab content are cleared
                container.empty();
                // check whether container element exists in dom
                if (!container.length > 0) {
                    errMsg = 'unable to find container for welcome screen with selector: ' +
                        _.get(options, 'container');
                    log.error(errMsg);
                    throw errMsg;
                }
                this.app = options.application;
                this._$parent_el = container;
                this._options = options;
            },

            hide: function(){
                //Hiding menu bar
                this._options.application.menuBar.show();
                this.$el.hide();
            },

            show: function(){
                //Hiding menu bar
                this._options.application.menuBar.hide();
                this.$el.show();
            },

            render: function () {
                var self = this;
                var backgroundDiv = $('

');
                var mainWelcomeDiv = $('

');
                var leftPane = $('

');
                var buttonWrap = $('

');
                var productNameWrap = $('

');
                var newButton = $('<button></button>');
                var openButton = $('<button></button>');

                var contentPane = $('

');
                var recentFilesPane = $('

');
                var samplesPane = $('

');
                var quickLinksPane = $('

');

                backgroundDiv.addClass(_.get(this._options, 'cssClass.parent'));
                mainWelcomeDiv.addClass(_.get(this._options, 'cssClass.outer'));
                leftPane.addClass(_.get(this._options, 'cssClass.leftPane'));
                buttonWrap.addClass(_.get(this._options, 'cssClass.buttonWrap'));
                productNameWrap.addClass(_.get(this._options, 'cssClass.productNameWrap'));
                newButton.addClass(_.get(this._options, 'cssClass.buttonNew'));
                openButton.addClass(_.get(this._options, 'cssClass.buttonOpen'));
                contentPane.addClass(_.get(this._options, 'cssClass.contentPane'));
                recentFilesPane.addClass(_.get(this._options, 'cssClass.recentFilesPane'));
                samplesPane.addClass(_.get(this._options, 'cssClass.samplesPane'));
                quickLinksPane.addClass(_.get(this._options, 'cssClass.quickLinksPane'));

                newButton.text("New");
                openButton.text("Open");
                buttonWrap.append(newButton);
                buttonWrap.append(openButton);

                var productNameWrapHeader = $('
' +
                    '
Stream Processor Studio

');
                productNameWrap.append(productNameWrapHeader);

                leftPane.append(buttonWrap);
                leftPane.append(productNameWrap);

                mainWelcomeDiv.append(leftPane);

                var recentFilesHeader = $('
Recently opened
');
                recentFilesPane.append(recentFilesHeader);

                var samplesHeader = $('
Try out samples
');
                samplesPane.append(samplesHeader)
                var bodyUlSampleContent = $('

');
                var moreSampleLink = $('' +
                    'More Samples');
                bodyUlSampleContent.attr('id', "sampleContent");
                samplesPane.append(bodyUlSampleContent);
                samplesPane.append(moreSampleLink);

                // Show the import file dialog when "More Samples" is clicked.
                $(moreSampleLink).click(function(){
                    command.dispatch("open-sample-file-open-dialog");
                });

                var quickLinkHeader = $('
Quick links
');
                quickLinksPane.append(quickLinkHeader);

                var bodyUlQuickLinkContent = $('
' +
                    '
Quick Start Guide
' +
                    '
Siddhi Grammar
' +
                    '
Q&A
' +
                    '
Tutorials
' +
                    '
Documentation
' +
                    '
Support

');

                quickLinksPane.append(bodyUlQuickLinkContent);
                contentPane.append(samplesPane);
                contentPane.append(quickLinksPane);

                mainWelcomeDiv.append(contentPane);
                backgroundDiv.append(mainWelcomeDiv);

                this._$parent_el.append(backgroundDiv);
                this.$el = backgroundDiv;

                var command = this._options.application.commandManager;
                var browserStorage = this._options.application.browserStorage;

                var samples = _.get(this._options, "samples", []);

                var config;
                var samplePreview;

                var self = this;
                var workspaceServiceURL = self.app.config.services.workspace.endpoint;
                var sampleServiceURL = workspaceServiceURL + "/read/sample";

                for (var i = 0; i < samples.length; i++) {

                    var payload = samples[i];

                    $.ajax({
                        type: "POST",
                        contentType: "text/plain; charset=utf-8",
                        url: sampleServiceURL,
                        data: payload,
                        async: false,
                        success: function(data, textStatus, xhr) {
                            var config =
                                {
                                    "sampleName": samples[i].replace(/^.*[\\\/]/, '').match(/[^.]*/i)[0],
                                    "content":data.content,
                                    "parentContainer": "#sampleContent",
                                    "firstItem": i === 0,
                                    "clickEventCallback": function (event) {
                                        event.preventDefault();
                                        var file = new File({
                                            content: data.content
                                            },{
                                            storage: browserStorage
                                        });
                                        self.app.commandManager.dispatch("create-new-tab", {tabOptions: {file: file}});
                                        browserStorage.put("pref:passedFirstLaunch", true);
                                    }
                                };
                            samplePreview = new SamplePreviewView(config);
                            samplePreview.render();
                        },
                        error: function() {
                            alertError("Unable to read a sample file.");
                            throw "Unable to read a sample file.";
                        }
                    });
                }

                var workExPath = 'workspace';
                command.dispatch("open-folder", workExPath);

                var command = this._options.application.commandManager;
                var browserStorage = this._options.application.browserStorage;

                // When "new" is clicked, open up an empty workspace.
                $(newButton).on('click', function () {
                    command.dispatch("create-new-tab");
                    browserStorage.put("pref:passedFirstLaunch", true);
                });

                // Show the open file dialog when "open" is clicked.
                $(openButton).click(function(){
                    command.dispatch("open-file-open-dialog");
                    browserStorage.put("pref:passedFirstLaunch", true);
                });

                // upon welcome tab remove, set flag to indicate first launch pass
                this._tab.on('removed', function(){
                    browserStorage.put("pref:passedFirstLaunch", true);
                });

                function alertError(errorMessage) {
                    var errorNotification = getErrorNotification(errorMessage);
                    $("#notification-container").append(errorNotification);
                    errorNotification.fadeTo(2000, 200).slideUp(1000, function () {
                        errorNotification.slideUp(1000);
                    });
                }

                function getErrorNotification(errorMessage) {
                    return $(
                        "
" +
                        "" +
                        errorMessage +
                        "" +
                        "
");
                };
            }
        });

        return FirstLaunchWelcomePage;

    });

<|endoftext|>


<commit_before><commit_msg>Test resource was missing<commit_after>class name1 {
    constructor(x) {
        this.x = x;
    }
}

// function name1() {
//     return "name1Value";
// }

// let name1 = "name1Value";

export default name1;
<|endoftext|>


<commit_before>/*
 * Copyright 1999-2018 Alibaba Group Holding Ltd.
 * 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.
 */

import React from 'react';
import PropTypes from 'prop-types';
import {
  Button,
  Field,
  Form,
  Grid,
  Input,
  Loading,
  Pagination,
  Table,
  Dialog,
  Message,
  ConfigProvider,
  Switch,
} from '@alifd/next';
import { request } from '../../../globalLib';
import RegionGroup from '../../../components/RegionGroup';
import EditServiceDialog from '../ServiceDetail/EditServiceDialog';
import ShowServiceCodeing from 'components/ShowCodeing/ShowServiceCodeing';

import './ServiceList.scss';

const FormItem = Form.Item;
const { Row, Col } = Grid;
const { Column } = Table;

@ConfigProvider.config
class ServiceList extends React.Component {
  static displayName = 'ServiceList';

  static propTypes = {
    locale: PropTypes.object,
    history: PropTypes.object,
  };

  constructor(props) {
    super(props);
    this.editServiceDialog = React.createRef();
    this.showcode = React.createRef();
    this.state = {
      loading: false,
      total: 0,
      pageSize: 10,
      currentPage: 1,
      keyword: '',
      dataSource: [],
      hasIpCount: true,
    };
    this.field = new Field(this);
  }

  openLoading() {
    this.setState({ loading: true });
  }

  closeLoading() {
    this.setState({ loading: false });
  }

  openEditServiceDialog() {
    try {
      this.editServiceDialog.current.getInstance().show(this.state.service);
    } catch (error) {}
  }

  queryServiceList() {
    const { currentPage, pageSize, keyword, withInstances = false, hasIpCount } = this.state;
    const parameter = [
      `hasIpCount=${hasIpCount}`,
      `withInstances=${withInstances}`,
      `pageNo=${currentPage}`,
      `pageSize=${pageSize}`,
      `keyword=${keyword}`,
    ];
    request({
      url: `v1/ns/catalog/services?${parameter.join('&')}`,
      beforeSend: () => this.openLoading(),
      success: ({ count = 0, serviceList = [] } = {}) => {
        this.setState({
          dataSource: serviceList,
          total: count,
        });
      },
      error: () =>
        this.setState({
          dataSource: [],
          total: 0,
          currentPage: 0,
        }),
      complete: () => this.closeLoading(),
    });
  }

  getQueryLater = () => {
    setTimeout(() => this.queryServiceList());
  };

  showcode = () => {
    setTimeout(() => this.queryServiceList());
  };

  /**
   *
   * Added method to open sample code window
   * @author yongchao9  #2019年05月18日 下午5:46:28
   *
   */
  showSampleCode(record) {
    this.showcode.current.getInstance().openDialog(record);
  }

  deleteService(service) {
    const { locale = {} } = this.props;
    const { prompt, promptDelete } = locale;
    Dialog.confirm({
      title: prompt,
      content: promptDelete,
      onOk: () => {
        request({
          method: 'DELETE',
          url: `v1/ns/service?serviceName=${service.name}&groupName=${service.groupName}`,
          dataType: 'text',
          beforeSend: () => this.openLoading(),
          success: res => {
            if (res !== 'ok') {
              Message.error(res);
              return;
            }
            this.queryServiceList();
          },
          error: res => Message.error(res.responseText || res.statusText),
          complete: () => this.closeLoading(),
        });
      },
    });
  }

  setNowNameSpace = (nowNamespaceName, nowNamespaceId) =>
    this.setState({
      nowNamespaceName,
      nowNamespaceId,
    });

  rowColor = row => ({ className: !row.healthyInstanceCount ? 'row-bg-red' : '' });

  render() {
    const { locale = {} } = this.props;
    const {
      pubNoData,
      serviceList,
      serviceName,
      serviceNamePlaceholder,
      hiddenEmptyService,
      query,
      create,
      operation,
      detail,
      sampleCode,
      deleteAction,
    } = locale;
    const {
      keyword,
      nowNamespaceName,
      nowNamespaceId,
      withInstances = false,
      hasIpCount,
    } = this.state;
    const { init, getValue } = this.field;
    this.init = init;
    this.getValue = getValue;

    return (

        <Loading
          shape="flower"
          style={{
            position: 'relative',
            width: '100%',
          }}
          visible={this.state.loading}
          tip="Loading..."
          color="#333"
        >

            <RegionGroup
              setNowNameSpace={this.setNowNameSpace}
              namespaceCallBack={this.getQueryLater}
            />

            {serviceList}
            |
            {nowNamespaceName}
            {nowNamespaceId}

          <Row
            className="demo-row"
            style={{
              marginBottom: 10,
              padding: 0,
            }}
          >
            <Col span="24">
              <Form inline field={this.field}>
                <FormItem label={serviceName}>
                  <Input
                    placeholder={serviceNamePlaceholder}
                    style={{ width: 200 }}
                    value={keyword}
                    onChange={keyword => this.setState({ keyword })}
                    onPressEnter={() =>
                      this.setState({ currentPage: 1 }, () => this.queryServiceList())
                    }
                  />
                </FormItem>
                <Form.Item label={`${hiddenEmptyService}:`}>
                  <Switch
                    checked={hasIpCount}
                    onChange={hasIpCount =>
                      this.setState({ hasIpCount, currentPage: 1 }, () => this.queryServiceList())
                    }
                  />
                </Form.Item>
                <FormItem label="">
                  <Button
                    type="primary"
                    onClick={() => this.setState({ currentPage: 1 }, () => this.queryServiceList())}
                    style={{ marginRight: 10 }}
                  >
                    {query}
                  </Button>
                </FormItem>
                <FormItem label="" style={{ float: 'right' }}>
                  <Button type="secondary" onClick={() => this.openEditServiceDialog()}>
                    {create}
                  </Button>
                </FormItem>
              </Form>
            </Col>
          </Row>
          <Row style={{ padding: 0 }}>
            <Col span="24" style={{ padding: 0 }}>

 this.rowColor(row)}
              >
                <Column title={locale.columnServiceName} dataIndex="name" />
                <Column title={locale.groupName} dataIndex="groupName" />
                <Column title={locale.columnClusterCount} dataIndex="clusterCount" />
                <Column title={locale.columnIpCount} dataIndex="ipCount" />
                <Column
                  title={locale.columnHealthyInstanceCount}
                  dataIndex="healthyInstanceCount"
                />
                <Column
                  title={operation}
                  align="center"
                  cell={(value, index, record) => (
                    // @author yongchao9  #2019年05月18日 下午5:46:28
                    /* Add a link to view "sample code"
                     replace the original button with a label,
                     which is consistent with the operation style in configuration management.
                     */

                          this.props.history.push(
                            `/serviceDetail?name=${record.name}&groupName=${record.groupName}`
                          )
                        }
                        style={{ marginRight: 5 }}
                      >
                        {detail}

                      |
                       this.showSampleCode(record)}>
                        {sampleCode}

                      |
                       this.deleteService(record)} style={{ marginRight: 5 }}>
                        {deleteAction}

                  )}
                />

            </Col>
          </Row>
          {this.state.total > this.state.pageSize && (

              <Pagination
                current={this.state.currentPage}
                total={this.state.total}
                pageSize={this.state.pageSize}
                onChange={currentPage =>
                  this.setState({ currentPage }, () => this.queryServiceList())
                }
              />

          )}
        </Loading>
        <ShowServiceCodeing ref={this.showcode} />
        <EditServiceDialog
          ref={this.editServiceDialog}
          openLoading={() => this.openLoading()}
          closeLoading={() => this.closeLoading()}
          queryServiceList={() => this.setState({ currentPage: 1 }, () => this.queryServiceList())}
        />

    );
  }
}

export default ServiceList;
<commit_msg>add refresh memory<commit_after>/*
 * Copyright 1999-2018 Alibaba Group Holding Ltd.
 * 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.
 */

import React from 'react';
import PropTypes from 'prop-types';
import {
  Button,
  Field,
  Form,
  Grid,
  Input,
  Loading,
  Pagination,
  Table,
  Dialog,
  Message,
  ConfigProvider,
  Switch,
} from '@alifd/next';
import { request } from '../../../globalLib';
import RegionGroup from '../../../components/RegionGroup';
import EditServiceDialog from '../ServiceDetail/EditServiceDialog';
import ShowServiceCodeing from 'components/ShowCodeing/ShowServiceCodeing';

import './ServiceList.scss';

const FormItem = Form.Item;
const { Row, Col } = Grid;
const { Column } = Table;

@ConfigProvider.config
class ServiceList extends React.Component {
  static displayName = 'ServiceList';

  static propTypes = {
    locale: PropTypes.object,
    history: PropTypes.object,
  };

  constructor(props) {
    super(props);
    this.editServiceDialog = React.createRef();
    this.showcode = React.createRef();
    this.state = {
      loading: false,
      total: 0,
      pageSize: 10,
      currentPage: 1,
      keyword: '',
      dataSource: [],
      hasIpCount: !(localStorage.getItem('hasIpCount') === 'false'),
    };
    this.field = new Field(this);
  }

  openLoading() {
    this.setState({ loading: true });
  }

  closeLoading() {
    this.setState({ loading: false });
  }

  openEditServiceDialog() {
    try {
      this.editServiceDialog.current.getInstance().show(this.state.service);
    } catch (error) {}
  }

  queryServiceList() {
    const { currentPage, pageSize, keyword, withInstances = false, hasIpCount } = this.state;
    const parameter = [
      `hasIpCount=${hasIpCount}`,
      `withInstances=${withInstances}`,
      `pageNo=${currentPage}`,
      `pageSize=${pageSize}`,
      `keyword=${keyword}`,
    ];
    request({
      url: `v1/ns/catalog/services?${parameter.join('&')}`,
      beforeSend: () => this.openLoading(),
      success: ({ count = 0, serviceList = [] } = {}) => {
        this.setState({
          dataSource: serviceList,
          total: count,
        });
      },
      error: () =>
        this.setState({
          dataSource: [],
          total: 0,
          currentPage: 0,
        }),
      complete: () => this.closeLoading(),
    });
  }

  getQueryLater = () => {
    setTimeout(() => this.queryServiceList());
  };

  showcode = () => {
    setTimeout(() => this.queryServiceList());
  };

  /**
   *
   * Added method to open sample code window
   * @author yongchao9  #2019年05月18日 下午5:46:28
   *
   */
  showSampleCode(record) {
    this.showcode.current.getInstance().openDialog(record);
  }

  deleteService(service) {
    const { locale = {} } = this.props;
    const { prompt, promptDelete } = locale;
    Dialog.confirm({
      title: prompt,
      content: promptDelete,
      onOk: () => {
        request({
          method: 'DELETE',
          url: `v1/ns/service?serviceName=${service.name}&groupName=${service.groupName}`,
          dataType: 'text',
          beforeSend: () => this.openLoading(),
          success: res => {
            if (res !== 'ok') {
              Message.error(res);
              return;
            }
            this.queryServiceList();
          },
          error: res => Message.error(res.responseText || res.statusText),
          complete: () => this.closeLoading(),
        });
      },
    });
  }

  setNowNameSpace = (nowNamespaceName, nowNamespaceId) =>
    this.setState({
      nowNamespaceName,
      nowNamespaceId,
    });

  rowColor = row => ({ className: !row.healthyInstanceCount ? 'row-bg-red' : '' });

  render() {
    const { locale = {} } = this.props;
    const {
      pubNoData,
      serviceList,
      serviceName,
      serviceNamePlaceholder,
      hiddenEmptyService,
      query,
      create,
      operation,
      detail,
      sampleCode,
      deleteAction,
    } = locale;
    const {
      keyword,
      nowNamespaceName,
      nowNamespaceId,
      withInstances = false,
      hasIpCount,
    } = this.state;
    const { init, getValue } = this.field;
    this.init = init;
    this.getValue = getValue;

    return (

        <Loading
          shape="flower"
          style={{
            position: 'relative',
            width: '100%',
          }}
          visible={this.state.loading}
          tip="Loading..."
          color="#333"
        >

            <RegionGroup
              setNowNameSpace={this.setNowNameSpace}
              namespaceCallBack={this.getQueryLater}
            />

            {serviceList}
            |
            {nowNamespaceName}
            {nowNamespaceId}

          <Row
            className="demo-row"
            style={{
              marginBottom: 10,
              padding: 0,
            }}
          >
            <Col span="24">
              <Form inline field={this.field}>
                <FormItem label={serviceName}>
                  <Input
                    placeholder={serviceNamePlaceholder}
                    style={{ width: 200 }}
                    value={keyword}
                    onChange={keyword => this.setState({ keyword })}
                    onPressEnter={() =>
                      this.setState({ currentPage: 1 }, () => this.queryServiceList())
                    }
                  />
                </FormItem>
                <Form.Item label={`${hiddenEmptyService}:`}>
                  <Switch
                    checked={hasIpCount}
                    onChange={hasIpCount =>
                      this.setState({ hasIpCount, currentPage: 1 }, () => {
                        localStorage.setItem('hasIpCount', hasIpCount);
                        this.queryServiceList();
                      })
                    }
                  />
                </Form.Item>
                <FormItem label="">
                  <Button
                    type="primary"
                    onClick={() => this.setState({ currentPage: 1 }, () => this.queryServiceList())}
                    style={{ marginRight: 10 }}
                  >
                    {query}
                  </Button>
                </FormItem>
                <FormItem label="" style={{ float: 'right' }}>
                  <Button type="secondary" onClick={() => this.openEditServiceDialog()}>
                    {create}
                  </Button>
                </FormItem>
              </Form>
            </Col>
          </Row>
          <Row style={{ padding: 0 }}>
            <Col span="24" style={{ padding: 0 }}>

 this.rowColor(row)}
              >
                <Column title={locale.columnServiceName} dataIndex="name" />
                <Column title={locale.groupName} dataIndex="groupName" />
                <Column title={locale.columnClusterCount} dataIndex="clusterCount" />
                <Column title={locale.columnIpCount} dataIndex="ipCount" />
                <Column
                  title={locale.columnHealthyInstanceCount}
                  dataIndex="healthyInstanceCount"
                />
                <Column
                  title={operation}
                  align="center"
                  cell={(value, index, record) => (
                    // @author yongchao9  #2019年05月18日 下午5:46:28
                    /* Add a link to view "sample code"
                     replace the original button with a label,
                     which is consistent with the operation style in configuration management.
                     */

                          this.props.history.push(
                            `/serviceDetail?name=${record.name}&groupName=${record.groupName}`
                          )
                        }
                        style={{ marginRight: 5 }}
                      >
                        {detail}

                      |
                       this.showSampleCode(record)}>
                        {sampleCode}

                      |
                       this.deleteService(record)} style={{ marginRight: 5 }}>
                        {deleteAction}

                  )}
                />

            </Col>
          </Row>
          {this.state.total > this.state.pageSize && (

              <Pagination
                current={this.state.currentPage}
                total={this.state.total}
                pageSize={this.state.pageSize}
                onChange={currentPage =>
                  this.setState({ currentPage }, () => this.queryServiceList())
                }
              />

          )}
        </Loading>
        <ShowServiceCodeing ref={this.showcode} />
        <EditServiceDialog
          ref={this.editServiceDialog}
          openLoading={() => this.openLoading()}
          closeLoading={() => this.closeLoading()}
          queryServiceList={() => this.setState({ currentPage: 1 }, () => this.queryServiceList())}
        />

    );
  }
}

export default ServiceList;
<|endoftext|>


<commit_before>/** Panel to show StaticFeedback info and create new static feedbacks.
 */
Ext.define('devilry.extjshelpers.assignmentgroup.StaticFeedbackEditor', {
    extend: 'devilry.extjshelpers.assignmentgroup.StaticFeedbackInfo',
    alias: 'widget.staticfeedbackeditor',
    requires: [
        'devilry.gradeeditors.DraftEditorWindow',
        'devilry.gradeeditors.RestfulRegistryItem'
    ],

    config: {
        /**
         * @cfg
         * A {@link devilry.extjshelpers.SingleRecordContainer} for GradeEditor Config.
         */
        gradeeditor_config_recordcontainer: undefined,

        /**
         * @cfg
         * Use the administrator RESTful interface to store drafts? If this is
         * ``false``, we use the examiner RESTful interface.
         */
        isAdministrator: false,

        assignmentgroup_recordcontainer: undefined
    },

    constructor: function(config) {
        return this.callParent([config]);
    },

    initComponent: function() {
        this.callParent(arguments);

        this.staticfeedback_recordcontainer.addListener('setRecord', this.onSetStaticFeedbackRecordInEditor, this);

        var me = this;
        this.createButton = Ext.create('Ext.button.Button', {
            text: 'Edit feedback',
            //iconCls: 'icon-edit-32',
            hidden: true,
            scale: 'large',
            listeners: {
                scope: this,
                click: this.loadGradeEditor
            }
        });
        this.editToolbar.add(this.createButton);

        this.addListener('afterStoreLoadMoreThanZero', this.showCreateButton, this);

        if(this.delivery_recordcontainer.record) {
            this.onLoadDeliveryInEditor();
        }
        this.delivery_recordcontainer.addListener('setRecord', this.onLoadDeliveryInEditor, this);

        if(this.gradeeditor_config_recordcontainer.record) {
            this.onLoadGradeEditorConfig();
        }
        this.gradeeditor_config_recordcontainer.addListener('setRecord', this.onLoadGradeEditorConfig, this);

        this.registryitem_recordcontainer = Ext.create('devilry.extjshelpers.SingleRecordContainer');
        this.registryitem_recordcontainer.addListener('setRecord', this.onLoadRegistryItem, this);

    },

    /**
     * @private
     * This is suffixed with InEditor to not crash with superclass.onLoadDelivery().
     */
    onLoadDeliveryInEditor: function() {
        this.showCreateButton();
    },

    /**
     * @private
     */
    onLoadGradeEditorConfig: function() {
        this.loadRegistryItem();
    },

    /**
     * @private
     */
    loadRegistryItem: function() {
        var registryitem_model = Ext.ModelManager.getModel('devilry.gradeeditors.RestfulRegistryItem');
        registryitem_model.load(this.gradeeditor_config_recordcontainer.record.data.gradeeditorid, {
            scope: this,
            success: function(record) {
                this.registryitem_recordcontainer.setRecord(record);
            }
        });
    },

    /**
     * @private
     */
    onLoadRegistryItem: function() {
        this.showCreateButton();
    },

    /**
     * @private
     * Show create button when:
     *
     * - Delivery has loaded.
     * - Grade editor config has loaded.
     * - Registry item has loaded.
     */
    showCreateButton: function() {
        if(this.gradeeditor_config_recordcontainer.record &&
                this.delivery_recordcontainer.record &&
                this.registryitem_recordcontainer.record) {
            this.createButton.show();
        }
    },

    /**
     * @private
     */
    loadGradeEditor: function() {
        Ext.widget('gradedrafteditormainwin', {
            deliveryid: this.delivery_recordcontainer.record.data.id,
            isAdministrator: this.isAdministrator,
            gradeeditor_config: this.gradeeditor_config_recordcontainer.record.data,
            registryitem: this.registryitem_recordcontainer.record.data,
            listeners: {
                scope: this,
                publishNewFeedback: this.onPublishNewFeedback
            }
        }).show();
    },

    /**
     * Overrides parent method to enable examiners to click to create feedback.
     */
    bodyWithNoFeedback: function() {
        var me = this;
        this.setBody({
            xtype: 'component',
            cls: 'no-feedback-editable',
            html: '
No feedback

Click to create feedback
',
            listeners: {
                render: function() {
                    this.getEl().addListener('mouseup', me.loadGradeEditor, me);
                }
            }
        });
    },

    /**
     * @private
     */
    onPublishNewFeedback: function() {
        this.hasNewPublishedStaticFeedback = true;
        this.onLoadDelivery();
    },

    /**
     * @private
     */
    onSetStaticFeedbackRecordInEditor: function() {
        if(this.hasNewPublishedStaticFeedback) {
            this.hasNewPublishedStaticFeedback = false;
            this.onNewPublishedStaticFeedback();
        }
    },

    /**
     * @private
     */
    onNewPublishedStaticFeedback: function() {
        var staticfeedback = this.staticfeedback_recordcontainer.record.data;
        if(staticfeedback.is_passing_grade) {
            this.closeAssignmentGroup();
        } else {
            this.onFailingGrade();
        }
    },

    /**
     * @private
     */
    closeAssignmentGroup: function() {
        this.assignmentgroup_recordcontainer.record.data.is_open = false;
        this.assignmentgroup_recordcontainer.record.save({
            scope: this,
            success: function(record) {
                // TODO: Notify about closing the group
                this.assignmentgroup_recordcontainer.fireSetRecordEvent();
            },
            failure: function() {
                throw "Failed to close group."
            }
        });
    },

    /**
     * @private
     */
    onFailingGrade: function() {
        console.log('failing grade...');
    }
});
<commit_msg>apps.extjshelpers: Only show 'Edit feedback' on open groups.<commit_after>/** Panel to show StaticFeedback info and create new static feedbacks.
 */
Ext.define('devilry.extjshelpers.assignmentgroup.StaticFeedbackEditor', {
    extend: 'devilry.extjshelpers.assignmentgroup.StaticFeedbackInfo',
    alias: 'widget.staticfeedbackeditor',
    requires: [
        'devilry.gradeeditors.DraftEditorWindow',
        'devilry.gradeeditors.RestfulRegistryItem'
    ],

    config: {
        /**
         * @cfg
         * A {@link devilry.extjshelpers.SingleRecordContainer} for GradeEditor Config.
         */
        gradeeditor_config_recordcontainer: undefined,

        /**
         * @cfg
         * Use the administrator RESTful interface to store drafts? If this is
         * ``false``, we use the examiner RESTful interface.
         */
        isAdministrator: false,

        assignmentgroup_recordcontainer: undefined
    },

    constructor: function(config) {
        return this.callParent([config]);
    },

    initComponent: function() {
        this.callParent(arguments);

        this.staticfeedback_recordcontainer.addListener('setRecord', this.onSetStaticFeedbackRecordInEditor, this);

        var me = this;
        this.createButton = Ext.create('Ext.button.Button', {
            text: 'Edit feedback',
            //iconCls: 'icon-edit-32',
            hidden: true,
            scale: 'large',
            listeners: {
                scope: this,
                click: this.loadGradeEditor
            }
        });
        this.editToolbar.add(this.createButton);

        this.addListener('afterStoreLoadMoreThanZero', this.showCreateButton, this);

        if(this.delivery_recordcontainer.record) {
            this.onLoadDeliveryInEditor();
        }
        this.delivery_recordcontainer.addListener('setRecord', this.onLoadDeliveryInEditor, this);

        if(this.gradeeditor_config_recordcontainer.record) {
            this.onLoadGradeEditorConfig();
        }
        this.gradeeditor_config_recordcontainer.addListener('setRecord', this.onLoadGradeEditorConfig, this);

        this.registryitem_recordcontainer = Ext.create('devilry.extjshelpers.SingleRecordContainer');
        this.registryitem_recordcontainer.addListener('setRecord', this.onLoadRegistryItem, this);

        this.assignmentgroup_recordcontainer.addListener('setRecord', this.showCreateButton, this);

    },

    /**
     * @private
     * This is suffixed with InEditor to not crash with superclass.onLoadDelivery().
     */
    onLoadDeliveryInEditor: function() {
        this.showCreateButton();
    },

    /**
     * @private
     */
    onLoadGradeEditorConfig: function() {
        this.loadRegistryItem();
    },

    /**
     * @private
     */
    loadRegistryItem: function() {
        var registryitem_model = Ext.ModelManager.getModel('devilry.gradeeditors.RestfulRegistryItem');
        registryitem_model.load(this.gradeeditor_config_recordcontainer.record.data.gradeeditorid, {
            scope: this,
            success: function(record) {
                this.registryitem_recordcontainer.setRecord(record);
            }
        });
    },

    /**
     * @private
     */
    onLoadRegistryItem: function() {
        this.showCreateButton();
    },

    /**
     * @private
     * Show create button when:
     *
     * - Delivery has loaded.
     * - Grade editor config has loaded.
     * - Registry item has loaded.
     */
    showCreateButton: function() {
        if(this.gradeeditor_config_recordcontainer.record &&
                this.delivery_recordcontainer.record &&
                this.registryitem_recordcontainer.record &&
                this.assignmentgroup_recordcontainer.record) {
            if(this.assignmentgroup_recordcontainer.record.data.is_open) {
                this.createButton.show();
            } else {
                this.createButton.hide();
            }
        }
    },

    /**
     * @private
     */
    loadGradeEditor: function() {
        Ext.widget('gradedrafteditormainwin', {
            deliveryid: this.delivery_recordcontainer.record.data.id,
            isAdministrator: this.isAdministrator,
            gradeeditor_config: this.gradeeditor_config_recordcontainer.record.data,
            registryitem: this.registryitem_recordcontainer.record.data,
            listeners: {
                scope: this,
                publishNewFeedback: this.onPublishNewFeedback
            }
        }).show();
    },

    /**
     * Overrides parent method to enable examiners to click to create feedback.
     */
    bodyWithNoFeedback: function() {
        var me = this;
        this.setBody({
            xtype: 'component',
            cls: 'no-feedback-editable',
            html: '
No feedback

Click to create feedback
',
            listeners: {
                render: function() {
                    this.getEl().addListener('mouseup', me.loadGradeEditor, me);
                }
            }
        });
    },

    /**
     * @private
     */
    onPublishNewFeedback: function() {
        this.hasNewPublishedStaticFeedback = true;
        this.onLoadDelivery();
    },

    /**
     * @private
     */
    onSetStaticFeedbackRecordInEditor: function() {
        if(this.hasNewPublishedStaticFeedback) {
            this.hasNewPublishedStaticFeedback = false;
            this.onNewPublishedStaticFeedback();
        }
    },

    /**
     * @private
     */
    onNewPublishedStaticFeedback: function() {
        var staticfeedback = this.staticfeedback_recordcontainer.record.data;
        if(staticfeedback.is_passing_grade) {
            this.closeAssignmentGroup();
        } else {
            this.onFailingGrade();
        }
    },

    /**
     * @private
     */
    closeAssignmentGroup: function() {
        this.assignmentgroup_recordcontainer.record.data.is_open = false;
        this.assignmentgroup_recordcontainer.record.save({
            scope: this,
            success: function(record) {
                // TODO: Notify about closing the group
                this.assignmentgroup_recordcontainer.fireSetRecordEvent();
            },
            failure: function() {
                throw "Failed to close group."
            }
        });
    },

    /**
     * @private
     */
    onFailingGrade: function() {
        console.log('failing grade...');
    }
});
<|endoftext|>


<commit_before>var mockPrompt = require("./support/mockPrompt");
var bp = require("../lib/BasicParameters");
var mockfs = require("mock-fs");
var fs = require("fs-extra");
var os = require("os");
var path = require("path");
var commons = require("@akashic/akashic-cli-commons");

describe("BasicParameters", function () {
	describe("updateConfigurationFile()", function () {
		var confPath = path.join(os.tmpdir(), ".akashicrc");
		var quietLogger = new commons.ConsoleLogger({quiet: true});

		beforeEach(() => {
			mockfs({});
			mockPrompt.mock({ width: 42, height: 27, fps: 30 });
		});

		afterEach(() => {
			mockPrompt.restore();
			mockfs.restore();
		});

		it("update game.json", done => {
			var conf = { width: 12, height: 23, fps: 34, assets: {} };
			fs.writeJsonSync(confPath, conf);
			bp.updateConfigurationFile(confPath, quietLogger)
				.then(() => {
					expect(fs.readJsonSync(confPath))
						.toEqual({width: 42, height: 27, fps: 30, assets: {}});
				})
				.then(done());
		});

		describe("parameter value is not number", () => {
			it("value is NaN", done => {
				mockPrompt.mock({ width: NaN, height: 27, fps: 30 });
				bp.updateConfigurationFile(confPath, quietLogger)
					.then(() => {done.fail();})
					.catch((err) => {
						expect(err).toBe("width must be a number");
						done();
					});
			});

			it("value is null", done => {
				mockPrompt.mock({ width: null, height: 27, fps: 30 });
				bp.updateConfigurationFile(confPath, quietLogger)
					.then(() => {done.fail();})
					.catch((err) => {
						expect(err).toBe("width must be a number");
						done();
					});
			});

			it("value is string", done => {
				mockPrompt.mock({ width: 111, height: "aaa", fps: 30 });
				bp.updateConfigurationFile(confPath, quietLogger)
					.then(() => {done.fail();})
					.catch((err) => {
						expect(err).toBe("height must be a number");
						done();
					});
			});

			it("value is undefined", done => {
				mockPrompt.mock({ width: 111, height: 222, fps: undefined });
				bp.updateConfigurationFile(confPath, quietLogger)
					.then(() => {done.fail();})
					.catch((err) => {
						expect(err).toBe("fps must be a number");
						done();
					});
			});

		});

	});
});
<commit_msg>Update spec<commit_after>var mockPrompt = require("./support/mockPrompt");
var bp = require("../lib/BasicParameters");
var mockfs = require("mock-fs");
var fs = require("fs-extra");
var os = require("os");
var path = require("path");
var commons = require("@akashic/akashic-cli-commons");

describe("BasicParameters", function () {
	describe("updateConfigurationFile()", function () {
		var confPath = path.join(os.tmpdir(), ".akashicrc");
		var quietLogger = new commons.ConsoleLogger({quiet: true});

		beforeEach(() => {
			mockfs({});
			mockPrompt.mock({ width: 42, height: 27, fps: 30 });
		});

		afterEach(() => {
			mockPrompt.restore();
			mockfs.restore();
		});

		it("update game.json", done => {
			var conf = { width: 12, height: 23, fps: 34, assets: {} };
			fs.writeJsonSync(confPath, conf);
			bp.updateConfigurationFile(confPath, quietLogger)
				.then(() => {
					expect(fs.readJsonSync(confPath))
						.toEqual({width: 42, height: 27, fps: 30, assets: {}});
				})
				.then(done, done.fail);
		});

		describe("parameter value is not number", () => {
			it("value is NaN", done => {
				mockPrompt.mock({ width: NaN, height: 27, fps: 30 });
				bp.updateConfigurationFile(confPath, quietLogger)
					.then(() => {done.fail();})
					.catch((err) => {
						expect(err).toBe("width must be a number");
						done();
					});
			});

			it("value is null", done => {
				mockPrompt.mock({ width: null, height: 27, fps: 30 });
				bp.updateConfigurationFile(confPath, quietLogger)
					.then(() => {done.fail();})
					.catch((err) => {
						expect(err).toBe("width must be a number");
						done();
					});
			});

			it("value is string", done => {
				mockPrompt.mock({ width: 111, height: "aaa", fps: 30 });
				bp.updateConfigurationFile(confPath, quietLogger)
					.then(() => {done.fail();})
					.catch((err) => {
						expect(err).toBe("height must be a number");
						done();
					});
			});

			it("value is undefined", done => {
				mockPrompt.mock({ width: 111, height: 222, fps: undefined });
				bp.updateConfigurationFile(confPath, quietLogger)
					.then(() => {done.fail();})
					.catch((err) => {
						expect(err).toBe("fps must be a number");
						done();
					});
			});

		});

	});
});
<|endoftext|>


<commit_before>/* eslint-disable */

import type { Range } from "./types"

import symlink from "./symlink"

// Manual testing should show this opens all-imports.js instead of symlink.js
console.log(symlink)

const range: Range /* Range */ = {
  start: 1,
  end: 10,
}

var testVar /* testVar */
let testLet /* testLet */
const testConst /* testConst */ = null

console.log({
  testVar /* log_testVar */,
  testLet /* log_testLet */,
  testConst /* log_testConst */,
})

function functionDeclaration /* functionDeclaration */(param1 /* param1 */) {
  console.log({
    param1 /* log_param1 */,
    functionDeclaration /* log_functionDeclaration */,
  })
}
console.log({
  functionDeclaration /* log2_functionDeclaration */,
})

function testDestructuring({
  dstrP1 /* dstrP1 */,
  dBar: [dstrP2 /* dstrP2 */],
}) {
  const { dstrC1 /* dstrC1 */, arr: [dstrC2 /* dstrC2 */] } = {}

  console.log({
    dstrP1 /* log_dstrP1 */,
    dstrP2 /* log_dstrP2 */,
    dstrC1 /* log_dstrC1 */,
    dstrC2 /* log_dstrC2 */,
  })
}

import otherDefault /* otherDefault */, {
  otherNamed /* otherNamed */,
} from "./other"
import { otherNamed2 /* otherNamed2 */ as renamed /* renamed */ } from "./other"

console.log({
  otherDefault /* log_otherDefault */,
  otherNamed /* log_otherNamed */,
  renamed /* log_renamed */,
})

export { testConst /* export_testConst */ }
export default functionDeclaration /* defaultExport */
export { namedExportFrom /* namedExportFrom */ } from "./exportFrom"
export defaultExportFrom /* defaultExportFrom */ from "./exportFrom"
export * from "./exportStar.js" /* exportStar */

if (/* if */ true) {
}

export const exportConst /* exportConst */ = null
export function exportFunction /* exportFunction */() {}
export const { name1 /* name1 */, x: { name2 /* name2 */ } } = {}
export const [name3 /* name3 */, [name4 /* name4 */]] = {}
<commit_msg>Refs #85 Add failing test for import('path')<commit_after>/* eslint-disable */

import type { Range } from "./types"

import symlink from "./symlink"

const dynamicSymlink = import("./symlink")

// Manual testing should show this opens all-imports.js instead of symlink.js
console.log(symlink)

const range: Range /* Range */ = {
  start: 1,
  end: 10,
}

var testVar /* testVar */
let testLet /* testLet */
const testConst /* testConst */ = null

console.log({
  testVar /* log_testVar */,
  testLet /* log_testLet */,
  testConst /* log_testConst */,
})

function functionDeclaration /* functionDeclaration */(param1 /* param1 */) {
  console.log({
    param1 /* log_param1 */,
    functionDeclaration /* log_functionDeclaration */,
  })
}
console.log({
  functionDeclaration /* log2_functionDeclaration */,
})

function testDestructuring({
  dstrP1 /* dstrP1 */,
  dBar: [dstrP2 /* dstrP2 */],
}) {
  const { dstrC1 /* dstrC1 */, arr: [dstrC2 /* dstrC2 */] } = {}

  console.log({
    dstrP1 /* log_dstrP1 */,
    dstrP2 /* log_dstrP2 */,
    dstrC1 /* log_dstrC1 */,
    dstrC2 /* log_dstrC2 */,
  })
}

import otherDefault /* otherDefault */, {
  otherNamed /* otherNamed */,
} from "./other"
import { otherNamed2 /* otherNamed2 */ as renamed /* renamed */ } from "./other"

console.log({
  otherDefault /* log_otherDefault */,
  otherNamed /* log_otherNamed */,
  renamed /* log_renamed */,
})

export { testConst /* export_testConst */ }
export default functionDeclaration /* defaultExport */
export { namedExportFrom /* namedExportFrom */ } from "./exportFrom"
export defaultExportFrom /* defaultExportFrom */ from "./exportFrom"
export * from "./exportStar.js" /* exportStar */

if (/* if */ true) {
}

export const exportConst /* exportConst */ = null
export function exportFunction /* exportFunction */() {}
export const { name1 /* name1 */, x: { name2 /* name2 */ } } = {}
export const [name3 /* name3 */, [name4 /* name4 */]] = {}
<|endoftext|>


<commit_before>"use strict";

var describedClass = require("../../lib/hdl/interParser");

describe("InterParser", function () {
  describe("parsing an intermediate derived from a truth table", function () {
    var graph = describedClass.parse({
      inputs: ["a", "b"],
      outputs: ["out"],
      table: [
        [["a", false], ["b", false], ["out", true]],
        [["a", false], ["b", true],  ["out", true]],
        [["a", true],  ["b", false], ["out", true]],
        [["a", true],  ["b", true],  ["out", false]]
      ]
    });

    it("builds the correct graph", function () {
      var instance0 = graph.findBy({ name: "instance-0" });
      var instance1 = graph.findBy({ name: "instance-1" });
      var instance2 = graph.findBy({ name: "instance-2" });
      var instance3 = graph.findBy({ name: "instance-3" });
      var a         = graph.findBy({ name: "a" });
      var b         = graph.findBy({ name: "b" });
      var out       = graph.findBy({ name: "out" });
      var lookup    = graph.findBy({ name: "lookup" });

      expect(instance0.value.type).toEqual("instance");
      expect(instance1.value.type).toEqual("instance");
      expect(instance2.value.type).toEqual("instance");
      expect(instance3.value.type).toEqual("instance");
      expect(a.value.type).toEqual("input");
      expect(b.value.type).toEqual("input");
      expect(out.value.type).toEqual("output");
      expect(lookup.value.type).toEqual("chip");

      var edges = instance0.outEdges;

      expect(edges[0].destination).toEqual(lookup);
      expect(edges[1].destination).toEqual(a);
      expect(edges[2].destination).toEqual(b);
      expect(edges[3].destination).toEqual(out);

      expect(edges[0].value).toBeUndefined();
      expect(edges[1].value).toEqual(false);
      expect(edges[2].value).toEqual(false);
      expect(edges[3].value).toEqual(true);

      edges = instance1.outEdges;

      expect(edges[0].destination).toEqual(lookup);
      expect(edges[1].destination).toEqual(a);
      expect(edges[2].destination).toEqual(b);
      expect(edges[3].destination).toEqual(out);

      expect(edges[0].value).toBeUndefined();
      expect(edges[1].value).toEqual(false);
      expect(edges[2].value).toEqual(true);
      expect(edges[3].value).toEqual(true);

      edges = instance2.outEdges;

      expect(edges[0].destination).toEqual(lookup);
      expect(edges[1].destination).toEqual(a);
      expect(edges[2].destination).toEqual(b);
      expect(edges[3].destination).toEqual(out);

      expect(edges[0].value).toBeUndefined();
      expect(edges[1].value).toEqual(true);
      expect(edges[2].value).toEqual(false);
      expect(edges[3].value).toEqual(true);

      edges = instance3.outEdges;

      expect(edges[0].destination).toEqual(lookup);
      expect(edges[1].destination).toEqual(a);
      expect(edges[2].destination).toEqual(b);
      expect(edges[3].destination).toEqual(out);

      expect(edges[0].value).toBeUndefined();
      expect(edges[1].value).toEqual(true);
      expect(edges[2].value).toEqual(true);
      expect(edges[3].value).toEqual(false);

      expect(graph.nodes.length).toEqual(8);
      expect(graph.edges.length).toEqual(16);
    });
  });
});
<commit_msg>Specify the behaviour of a parser for parts<commit_after>"use strict";

var describedClass = require("../../lib/hdl/interParser");

describe("InterParser", function () {
  describe("parsing an intermediate derived from a truth table", function () {
    var graph = describedClass.parse({
      inputs: ["a", "b"],
      outputs: ["out"],
      table: [
        [["a", false], ["b", false], ["out", true]],
        [["a", false], ["b", true],  ["out", true]],
        [["a", true],  ["b", false], ["out", true]],
        [["a", true],  ["b", true],  ["out", false]]
      ]
    });

    it("builds the correct graph", function () {
      var instance0 = graph.findBy({ name: "instance-0" });
      var instance1 = graph.findBy({ name: "instance-1" });
      var instance2 = graph.findBy({ name: "instance-2" });
      var instance3 = graph.findBy({ name: "instance-3" });
      var a         = graph.findBy({ name: "a" });
      var b         = graph.findBy({ name: "b" });
      var out       = graph.findBy({ name: "out" });
      var lookup    = graph.findBy({ name: "lookup" });

      expect(instance0.value.type).toEqual("instance");
      expect(instance1.value.type).toEqual("instance");
      expect(instance2.value.type).toEqual("instance");
      expect(instance3.value.type).toEqual("instance");
      expect(a.value.type).toEqual("input");
      expect(b.value.type).toEqual("input");
      expect(out.value.type).toEqual("output");
      expect(lookup.value.type).toEqual("chip");

      var edges = instance0.outEdges;

      expect(edges[0].destination).toEqual(lookup);
      expect(edges[1].destination).toEqual(a);
      expect(edges[2].destination).toEqual(b);
      expect(edges[3].destination).toEqual(out);

      expect(edges[0].value).toBeUndefined();
      expect(edges[1].value).toEqual(false);
      expect(edges[2].value).toEqual(false);
      expect(edges[3].value).toEqual(true);

      edges = instance1.outEdges;

      expect(edges[0].destination).toEqual(lookup);
      expect(edges[1].destination).toEqual(a);
      expect(edges[2].destination).toEqual(b);
      expect(edges[3].destination).toEqual(out);

      expect(edges[0].value).toBeUndefined();
      expect(edges[1].value).toEqual(false);
      expect(edges[2].value).toEqual(true);
      expect(edges[3].value).toEqual(true);

      edges = instance2.outEdges;

      expect(edges[0].destination).toEqual(lookup);
      expect(edges[1].destination).toEqual(a);
      expect(edges[2].destination).toEqual(b);
      expect(edges[3].destination).toEqual(out);

      expect(edges[0].value).toBeUndefined();
      expect(edges[1].value).toEqual(true);
      expect(edges[2].value).toEqual(false);
      expect(edges[3].value).toEqual(true);

      edges = instance3.outEdges;

      expect(edges[0].destination).toEqual(lookup);
      expect(edges[1].destination).toEqual(a);
      expect(edges[2].destination).toEqual(b);
      expect(edges[3].destination).toEqual(out);

      expect(edges[0].value).toBeUndefined();
      expect(edges[1].value).toEqual(true);
      expect(edges[2].value).toEqual(true);
      expect(edges[3].value).toEqual(false);

      expect(graph.nodes.length).toEqual(8);
      expect(graph.edges.length).toEqual(16);
    });
  });

  describe("parsing an intermediate derived from a list of parts", function () {
    var graph = describedClass.parse({
      inputs: ["a", "b"],
      outputs: ["out"],
      parts: [
        ["nand", [["a", "a"], ["b", "b"], ["out", "x"]]],
        ["nand", [["a", "x"], ["b", "x"], ["out", "out"]]]
      ]
    });

    it("builds the correct graph", function () {
      var instance0 = graph.findBy({ name: "instance-0" });
      var instance1 = graph.findBy({ name: "instance-1" });
      var a         = graph.findBy({ name: "a" });
      var b         = graph.findBy({ name: "b" });
      var out       = graph.findBy({ name: "out" });
      var x         = graph.findBy({ name: "x" });
      var nand      = graph.findBy({ name: "nand" });

      expect(instance0.value.type).toEqual("instance");
      expect(instance1.value.type).toEqual("instance");
      expect(a.value.type).toEqual("input");
      expect(b.value.type).toEqual("input");
      expect(out.value.type).toEqual("output");
      expect(x.value.type).toEqual("intermediate");
      expect(nand.value.type).toEqual("chip");

      var edges = instance0.outEdges;

      expect(edges[0].destination).toEqual(nand);
      expect(edges[1].destination).toEqual(a);
      expect(edges[2].destination).toEqual(b);
      expect(edges[3].destination).toEqual(x);

      expect(edges[0].value).toBeUndefined();
      expect(edges[1].value).toEqual("a");
      expect(edges[2].value).toEqual("b");
      expect(edges[3].value).toEqual("out");

      edges = instance1.outEdges;

      expect(edges[0].destination).toEqual(nand);
      expect(edges[1].destination).toEqual(x);
      expect(edges[2].destination).toEqual(x);
      expect(edges[3].destination).toEqual(out);

      expect(edges[0].value).toBeUndefined();
      expect(edges[1].value).toEqual("a");
      expect(edges[2].value).toEqual("b");
      expect(edges[3].value).toEqual("out");

      expect(graph.nodes.length).toEqual(7);
      expect(graph.edges.length).toEqual(8);
    });
  });
});
<|endoftext|>


<commit_before>var config = require('../config.json');
var RedisPool = require('../../index');

var redisPool;

beforeAll(function() {
  redisPool = new RedisPool(config.redis, {
    max: 10,
    min: 2
  });
});

describe('initialize', function() {
  it('should initialize the module', function(done) {
    expect(redisPool).not.toBe(null);
    done();
  });

  it('should initialize the module with a given db', function(done) {
    expect(redisPool).not.toBe(null);
    done();
  });
});

describe('acquire', function() {
  it('should acquire a database connection', function(done) {
    redisPool.acquire(function(err, conn) {
      expect(err).toBe(null);
      expect(conn).not.toBe(null);
      redisPool.release(conn);
      done();
    });
  });

  it('should acquire a database connection with a priority', function(done) {
    redisPool.acquire(function(err, conn) {
      expect(err).toBe(null);
      expect(conn).not.toBe(null);
      redisPool.release(conn);
      done();
    }, 0);
  });
});

describe('acquireDb', function() {
  it('should acquire a given database connection', function(done) {
    redisPool.acquireDb(function(err, conn) {
      expect(err).toBe(null);
      expect(conn).not.toBe(null);
      redisPool.release(conn);
      done();
    }, 1);
  });
});

describe('drain', function() {
  it('should drains the connection pool and call the callback', function(done) {
    redisPool.drain(done);
  });
});

describe('getName', function() {
  it('should returns factory.name for this pool', function(done) {
    expect(redisPool.getName()).not.toBe(null);
    done();
  });
});

describe('getPoolSize', function() {
  it('should returns number of resources in the pool', function(done) {
    expect(redisPool.getPoolSize()).not.toBe(null);
    done();
  });
});<commit_msg>Add tests : availableObjectsCount<commit_after>var config = require('../config.json');
var RedisPool = require('../../index');

var redisPool;

beforeAll(function() {
  redisPool = new RedisPool(config.redis, {
    max: 10,
    min: 2
  });
});

describe('initialize', function() {
  it('should initialize the module', function(done) {
    expect(redisPool).not.toBe(null);
    done();
  });

  it('should initialize the module with a given db', function(done) {
    expect(redisPool).not.toBe(null);
    done();
  });
});

describe('acquire', function() {
  it('should acquire a database connection', function(done) {
    redisPool.acquire(function(err, conn) {
      expect(err).toBe(null);
      expect(conn).not.toBe(null);
      redisPool.release(conn);
      done();
    });
  });

  it('should acquire a database connection with a priority', function(done) {
    redisPool.acquire(function(err, conn) {
      expect(err).toBe(null);
      expect(conn).not.toBe(null);
      redisPool.release(conn);
      done();
    }, 0);
  });
});

describe('acquireDb', function() {
  it('should acquire a given database connection', function(done) {
    redisPool.acquireDb(function(err, conn) {
      expect(err).toBe(null);
      expect(conn).not.toBe(null);
      redisPool.release(conn);
      done();
    }, 1);
  });
});

describe('drain', function() {
  it('should drains the connection pool and call the callback', function(done) {
    redisPool.drain(done);
  });
});

describe('getName', function() {
  it('should returns factory.name for this pool', function(done) {
    expect(redisPool.getName()).not.toBe(null);
    done();
  });
});

describe('getPoolSize', function() {
  it('should returns number of resources in the pool', function(done) {
    expect(redisPool.getPoolSize()).not.toBe(null);
    done();
  });
});

describe('availableObjectsCount', function() {
  it('should returns number of unused resources in the pool', function(done) {
    expect(redisPool.availableObjectsCount()).not.toBe(null);
    done();
  });
});<|endoftext|>


<commit_before>'use strict';

// modules dependencies
var mongoat = require('../../index');

var _this;

// test update method
describe('Versioning', function () {
  // connect to db before all tests
  beforeAll(function (done) {
    _this = this;

    mongoat.MongoClient.connect('mongodb://localhost:27017/mongoatTest')
    .then(function (db) {
      db.dropDatabase();
      _this.testDb = db;
      _this.testCol = db.collection('Person.verioning');
      _this.testCol.datetime(true);
      _this.testCol.version(true);

      // add before update hooks
      _this.testCol.before('update', function (object) {
        expect(typeof object).toBe('object');
        return object;
      });

      _this.testCol.before('update', function (object) {
        expect(typeof object).toBe('object');
        return object;
      });

      // add after update hooks
      _this.testCol.after('update', function (object) {
        expect(typeof object).toBe('object');
        return object;
      });

      _this.testCol.after('update', function (object) {
        expect(typeof object).toBe('object');
        return object;
      });

      done();
    });
  });

  // close db after all tests
  afterAll(function (done) {
    _this.testCol = _this.testDb.collection('Person.verioning.vermongo');

    _this.testCol.find()
    .toArray()
    .then(function (mongoArray) {
      expect(mongoArray.length).toBe(6);

      _this.testDb.dropDatabase();
      _this.testDb.close();

      done();
    });
  });

  // test restore
  it('should throw error',
  function (done) {
   _this.testCol.restore(3)
    .catch(function (err) {
      expect(typeof err).toBe('object');
      expect(err.message).toBe('Nothing to restore');

      done();
    });
  });

  // test insert
  it('should insert new document to collection',
  function (done) {
    _this.testCol.insert({
      firstName: 'Hichem',
      lastName: 'KHATAl',
      age: 28
    }).then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(typeof mongObject.result).toBe('object');
      expect(mongObject.result.ok).toBe(1);
      expect(mongObject.result.n).toBe(1);
      done();
    });
  });

  // test upsert
  it('should upsert new document to collection',
  function (done) {
    _this.testCol.update(
      { firstName: 'Yacine' },
      { $setOnInsert: { lastName: 'KHATAL', age: 25 } },
      { upsert: true }
    ).then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(typeof mongObject.result).toBe('object');
      expect(mongObject.result.ok).toBe(1);
      expect(mongObject.result.n).toBe(1);
      expect(mongObject.result.nModified).toBe(0);

      done();
    });
  });

  // test update
  it('should update document from collection',
  function (done) {
    _this.testCol.update(
      { firstName: 'Yacine' },
      { $set: { age: 30, company: 'Dial Once' } }
    ).then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(typeof mongObject.result).toBe('object');
      expect(mongObject.result.ok).toBe(1);
      expect(mongObject.result.n).toBe(1);
      expect(mongObject.result.nModified).toBe(1);

      done();
    });
  });

  // test update
  it('should update document from collection',
  function (done) {
    _this.testCol.update(
      { firstName: 'Yacine' },
      { $set: { age: 35, job: 'software engineer' } }
    ).then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(typeof mongObject.result).toBe('object');
      expect(mongObject.result.ok).toBe(1);
      expect(mongObject.result.n).toBe(1);
      expect(mongObject.result.nModified).toBe(1);

      done();
    });
  });

  // test restore
  it('should throw error',
  function (done) {
   _this.testCol.restore(-7)
    .catch(function (err) {
      expect(typeof err).toBe('object');
      expect(err.message).toBe('Nothing to restore');

      done();
    });
  });

  // test restore
  it('should restore version 2 document by version',
  function (done) {
    _this.testCol.restore(2)
    .then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(mongObject.firstName).toBe('Yacine');
      expect(mongObject.lastName).toBe('KHATAL');
      expect(mongObject.age).toBe(30);
      expect(mongObject.company).toBe('Dial Once');
      expect(mongObject.job).toBeUndefined();

      done();
    });
  });

  // test restore
  it('should restore version 3 document by version',
  function (done) {
    _this.testCol.restore(3)
    .then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(mongObject.firstName).toBe('Yacine');
      expect(mongObject.lastName).toBe('KHATAL');
      expect(mongObject.age).toBe(35);
      expect(mongObject.job).toBe('software engineer');
      expect(mongObject.company).toBe('Dial Once');

      done();
    });
  });

  // test restore
  it('should restore last version of the document by version',
  function (done) {
    _this.testCol.restore(0)
    .then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(mongObject.firstName).toBe('Yacine');
      expect(mongObject.lastName).toBe('KHATAL');
      expect(mongObject.age).toBe(30);
      expect(mongObject.company).toBe('Dial Once');
      expect(mongObject.job).toBeUndefined();

      done();
    });
  });

  // test restore
  it('should restore version -2 of the document by version',
  function (done) {
    _this.testCol.restore(-4)
    .then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(mongObject.firstName).toBe('Yacine');
      expect(mongObject.lastName).toBe('KHATAL');
      expect(mongObject.age).toBe(25);
      expect(mongObject.job).toBeUndefined();
      expect(mongObject.company).toBeUndefined();

      done();
    });
  });
});
<commit_msg>Update spec according to restore method changes<commit_after>'use strict';

// modules dependencies
var mongoat = require('../../index');

var _this;
var id;

// test update method
describe('Versioning', function () {
  // connect to db before all tests
  beforeAll(function (done) {
    _this = this;

    mongoat.MongoClient.connect('mongodb://localhost:27017/mongoatTest')
    .then(function (db) {
      db.dropDatabase();
      _this.testDb = db;
      _this.testCol = db.collection('Person.verioning');
      _this.testCol.datetime(true);
      _this.testCol.version(true);

      // add before update hooks
      _this.testCol.before('update', function (object) {
        expect(typeof object).toBe('object');
        return object;
      });

      _this.testCol.before('update', function (object) {
        expect(typeof object).toBe('object');
        return object;
      });

      // add after update hooks
      _this.testCol.after('update', function (object) {
        expect(typeof object).toBe('object');
        return object;
      });

      _this.testCol.after('update', function (object) {
        expect(typeof object).toBe('object');
        return object;
      });

      done();
    });
  });

  // close db after all tests
  afterAll(function (done) {
    _this.testCol = _this.testDb.collection('Person.verioning.vermongo');

    _this.testCol.find()
    .toArray()
    .then(function (mongoArray) {
      expect(mongoArray.length).toBe(6);

      _this.testDb.dropDatabase();
      _this.testDb.close();

      done();
    });
  });

  // test restore
  it('should return null',
  function (done) {
    _this.testCol.restore()
    .then(function (document) {
      expect(document).toBe(null);

      done();
    });
  });

  // test insert
  it('should insert new document to collection',
  function (done) {
    _this.testCol.insert({
      firstName: 'Yacine',
      lastName: 'KHATAL',
      age: 25
    }).then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(typeof mongObject.result).toBe('object');
      expect(mongObject.result.ok).toBe(1);
      expect(mongObject.result.n).toBe(1);
      id = mongObject.ops[0]._id;

      done();
    });
  });

  // test upsert
  it('should upsert new document to collection',
  function (done) {
    _this.testCol.update(
      { firstName: 'Hichem' },
      { $setOnInsert: { lastName: 'KHATAL', age: 28 } },
      { upsert: true }
    ).then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(typeof mongObject.result).toBe('object');
      expect(mongObject.result.ok).toBe(1);
      expect(mongObject.result.n).toBe(1);
      expect(mongObject.result.nModified).toBe(0);

      done();
    });
  });

  // test update
  it('should update document from collection',
  function (done) {
    _this.testCol.update(
      { firstName: 'Yacine' },
      { $set: { age: 30, company: 'Dial Once' } }
    ).then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(typeof mongObject.result).toBe('object');
      expect(mongObject.result.ok).toBe(1);
      expect(mongObject.result.n).toBe(1);
      expect(mongObject.result.nModified).toBe(1);

      done();
    });
  });

  // test update
  it('should update document from collection',
  function (done) {
    _this.testCol.update(
      { firstName: 'Yacine' },
      { $set: { age: 35, job: 'software engineer' } }
    ).then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(typeof mongObject.result).toBe('object');
      expect(mongObject.result.ok).toBe(1);
      expect(mongObject.result.n).toBe(1);
      expect(mongObject.result.nModified).toBe(1);

      done();
    });
  });

  // test restore
  it('should throw error',
  function (done) {
    _this.testCol.restore(id, -7)
    .then(function (document) {
      expect(document).toBe(null);

      done();
    });
  });

  // test restore
  it('should restore version 2 document by version',
  function (done) {
    _this.testCol.restore(id, 2)
    .then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(mongObject.firstName).toBe('Yacine');
      expect(mongObject.lastName).toBe('KHATAL');
      expect(mongObject.age).toBe(30);
      expect(mongObject.company).toBe('Dial Once');
      expect(mongObject.job).toBeUndefined();

      done();
    });
  });

  // test restore
  it('should restore version 3 document by version',
  function (done) {
    _this.testCol.restore(id, 3)
    .then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(mongObject.firstName).toBe('Yacine');
      expect(mongObject.lastName).toBe('KHATAL');
      expect(mongObject.age).toBe(35);
      expect(mongObject.job).toBe('software engineer');
      expect(mongObject.company).toBe('Dial Once');

      done();
    });
  });

  // test restore
  it('should restore last version of the document by version',
  function (done) {
    _this.testCol.restore(id, 0)
    .then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(mongObject.firstName).toBe('Yacine');
      expect(mongObject.lastName).toBe('KHATAL');
      expect(mongObject.age).toBe(30);
      expect(mongObject.company).toBe('Dial Once');
      expect(mongObject.job).toBeUndefined();

      done();
    });
  });

  // test restore
  it('should restore version -2 of the document by version',
  function (done) {
    _this.testCol.restore(id, -4)
    .then(function (mongObject) {
      expect(typeof mongObject).toBe('object');
      expect(mongObject.firstName).toBe('Yacine');
      expect(mongObject.lastName).toBe('KHATAL');
      expect(mongObject.age).toBe(25);
      expect(mongObject.job).toBeUndefined();
      expect(mongObject.company).toBeUndefined();

      done();
    });
  });
});
<|endoftext|>


<commit_before>define(["js/data/Collection"], function(Collection) {
    return Collection.inherit("sprd.collection.Articles", {
        // TODO: use this collection during reference resolving
        // TODO: always fetch currency with article
    });
});<commit_msg>removed Articles as Collection<commit_after><|endoftext|>


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

    /* jshint -W098 */

    function HackathorgCreateController($scope, Global, HackathorgCreate, $stateParams) {
        $scope.global = Global;
        $scope.package = {
            name: 'hackathorg-events'
        };

        $scope.eventTags = ['jamesmahoney200@hotmail.com', 'mike_380@live.co.uk'];
        $scope.readonly = false;
        $scope.attendees;
        $scope.mentors;

        $scope.skills = [{
           'type': 'All'
        }, {
           'type': 'Beginner & above'
        }, {
           'type': 'Intermediate & above'
        }, {
            'type': 'Advanced'
        }];

        $scope.startDate = new Date();
        $scope.endDate = new Date();
        $scope.minDate = new Date(
              $scope.startDate.getFullYear(),
              $scope.startDate.getMonth(),
              $scope.startDate.getDate());

        $scope.checkCircle = function() {
            EventService.checkCircle($stateParams.circle).then(function(response) {
                $scope.res = response;
                $scope.resStatus = 'info';
            }, function(error) {
                $scope.res = error;
                $scope.resStatus = 'danger';
            });
        };
    }

    angular
        .module('mean.hackathorg-events')
        .controller('HackathorgCreateController', HackathorgCreateController);

    HackathorgCreateController.$inject = ['$scope', 'Global', 'HackathorgCreate', '$stateParams'];

})();
<commit_msg>Fix create page<commit_after>(function() {
    'use strict';

    /* jshint -W098 */

    function HackathorgCreateController($scope, Global, $stateParams, EventService) {
        $scope.global = Global;
        $scope.package = {
            name: 'hackathorg-events'
        };

        $scope.eventTags = ['jamesmahoney200@hotmail.com', 'mike_380@live.co.uk'];
        $scope.readonly = false;
        $scope.attendees;
        $scope.mentors;

        $scope.skills = [{
           'type': 'All'
        }, {
           'type': 'Beginner & above'
        }, {
           'type': 'Intermediate & above'
        }, {
            'type': 'Advanced'
        }];

        $scope.startDate = new Date();
        $scope.endDate = new Date();
        $scope.minDate = new Date(
              $scope.startDate.getFullYear(),
              $scope.startDate.getMonth(),
              $scope.startDate.getDate());

        $scope.checkCircle = function() {
            EventService.checkCircle($stateParams.circle).then(function(response) {
                $scope.res = response;
                $scope.resStatus = 'info';
            }, function(error) {
                $scope.res = error;
                $scope.resStatus = 'danger';
            });
        };
    }

    angular
        .module('mean.hackathorg-events')
        .controller('HackathorgCreateController', HackathorgCreateController);

    HackathorgCreateController.$inject = ['$scope', 'Global', '$stateParams', 'EventService'];

})();
<|endoftext|>