{"size": 1537, "ext": "js", "max_stars_repo_path": "specs/functional/reversing_messages_in_the_middle_of_the_chain.specs.js", "max_stars_repo_name": "valentin-nemcev/transmitter.js", "max_stars_repo_stars_event_min_datetime": "2016-05-06T00:06:41.000Z", "max_stars_repo_stars_event_max_datetime": "2016-05-06T08:42:24.000Z", "max_issues_repo_path": "specs/functional/reversing_messages_in_the_middle_of_the_chain.specs.js", "max_issues_repo_name": "valentin-nemcev/transmitter.js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "specs/functional/reversing_messages_in_the_middle_of_the_chain.specs.js", "max_forks_repo_name": "valentin-nemcev/transmitter.js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.5576923077, "max_line_length": 72, "alphanum_fraction": 0.6356538712}
import * as Transmitter from 'transmitter';

describe('Reversing messages in the middle of the chain', function() {

  before(function() {
    this.define('button', new Transmitter.Nodes.ValueSourceNode());
    this.define('textInput', new Transmitter.Nodes.ValueNode());
    this.define('tagList', new Transmitter.Nodes.ListNode());

    Transmitter.startTransmission( (tr) => {
      new Transmitter.Channels.SimpleChannel()
        .inBackwardDirection()
        .fromSources(this.button, this.textInput)
        .toTarget(this.tagList)
        .withTransform( ([buttonWasClickedPayload, textValuePayload]) =>
          textValuePayload.replaceByNoOp(buttonWasClickedPayload)
            .toAppendAction()
        )
        .init(tr);

      new Transmitter.Channels.SimpleChannel()
        .inForwardDirection()
        .fromSource(this.button)
        .toTarget(this.textInput)
        .withTransform( (buttonWasClickedPayload) =>
          buttonWasClickedPayload.map( () => '' )
        )
        .init(tr);

      this.tagList.set(['value 1']).init(tr);
      this.textInput.set('value 2').init(tr);
    });
  });


  specify('when button is clicked', function() {
    Transmitter.startTransmission( (tr) =>
      this.button.originateValue(tr, 'click')
    );
  });


  specify('text input value should be added to list', function() {
    expect(this.tagList.get()).to.deep.equal(['value 1', 'value 2']);
  });


  specify('text input value should cleared', function() {
    expect(this.textInput.get()).to.equal('');
  });
});
