hunk.code_window:         this.lastTime = 0;
           this.handleSubmit = this.handleSubmit.bind(this);
           this.postMsgKeyPress = this.postMsgKeyPress.bind(this);
           this.handleChange = this.handleChange.bind(this);
           this.handleUploadClick = this.handleUploadClick.bind(this);
           this.handleUploadStart = this.handleUploadStart.bind(this);
           this.handleFileUploadComplete = this.handleFileUploadComplete.bind(this);
           this.handleUploadError = this.handleUploadError.bind(this);
           this.removePreview = this.removePreview.bind(this);
  
hunk.labels: keep keep keep keep keep replace keep keep keep keep
hunk.after_edit:         this.handleFileUploadChange = this.handleFileUploadChange.bind(this);
  
hunk.file_path: webapp/components/create_post.jsx
hunk.type: replace
file: // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
  // See License.txt for license information.
  
  import Client from 'client/client.jsx';
  import WebSocketClient from 'client/websocket_client.jsx';
  import jqd from 'jquery-deferred';
  
  var HEADER_TOKEN = 'token';
  
  class TestHelperClass {
      basicClient = () => {
          return this.basicc;
      }
  
      basicWebSocketClient = () => {
          return this.basicwsc;
      }
  
      basicTeam = () => {
          return this.basict;
      }
  
      basicUser = () => {
          return this.basicu;
      }
  
      basicChannel = () => {
          return this.basicch;
      }
  
      basicPost = () => {
          return this.basicp;
      }
  
      generateId = () => {
          // implementation taken from http://stackoverflow.com/a/2117523
          var id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
  
          id = id.replace(/[xy]/g, function replaceRandom(c) {
              var r = Math.floor(Math.random() * 16);
  
              var v;
              if (c === 'x') {
                  v = r;
              } else {
                  v = (r & 0x3) | 0x8;
              }
  
              return v.toString(16);
          });
  
          return 'uid' + id;
      }
  
      createClient() {
          var c = new Client();
          c.setUrl('http://localhost:8065');
          c.useHeaderToken();
          c.enableLogErrorsToConsole(true);
          return c;
      }
  
      createWebSocketClient(token) {
          var ws = new WebSocketClient();
          ws.initialize('http://localhost:8065/api/v3/users/websocket', token);
          return ws;
      }
  
      fakeEmail = () => {
          return 'success' + this.generateId() + '@simulator.amazonses.com';
      }
  
      fakeUser = () => {
          var user = {};
          user.email = this.fakeEmail();
          user.allow_marketing = true;
          user.password = 'password1';
          user.username = this.generateId();
          return user;
      }
  
      fakeTeam = () => {
          var team = {};
          team.name = this.generateId();
          team.display_name = `Unit Test ${team.name}`;
          team.type = 'O';
          team.email = this.fakeEmail();
          team.allowed_domains = '';
          return team;
      }
  
      fakeChannel = () => {
          var channel = {};
          channel.name = this.generateId();
          channel.display_name = `Unit Test ${channel.name}`;
          channel.type = 'O'; // open channel
          return channel;
      }
  
      fakePost = () => {
          var post = {};
          post.message = `Unit Test ${this.generateId()}`;
          return post;
      }
  
      initBasic = (callback, connectWS) => {
          this.basicc = this.createClient();
  
          function throwerror(err) {
              throw err;
          }
  
          var d1 = jqd.Deferred();
          var email = this.fakeEmail();
          var user = this.fakeUser();
          var team = this.fakeTeam();
          team.email = email;
          user.email = email;
          var self = this;
  
          this.basicClient().createUser(
              user,
              function(ruser) {
                  self.basicu = ruser;
                  self.basicu.password = user.password;
                  self.basicClient().login(
                      self.basicu.email,
                      self.basicu.password,
                      null,
                      function(data, res) {
                          if (connectWS) {
                              self.basicwsc = self.createWebSocketClient(res.header[HEADER_TOKEN]);
                          }
                          self.basicClient().useHeaderToken();
                          self.basicClient().createTeam(team,
                              function(rteam) {
                                  self.basict = rteam;
                                  self.basicClient().setTeamId(rteam.id);
                                  var channel = self.fakeChannel();
                                  channel.team_id = self.basicTeam().id;
                                  self.basicClient().createChannel(
                                      channel,
                                      function(rchannel) {
                                          self.basicch = rchannel;
                                          var post = self.fakePost();
                                          post.channel_id = rchannel.id;
  
                                          self.basicClient().createPost(
                                              post,
                                              function(rpost) {
                                                  self.basicp = rpost;
                                                  d1.resolve();
                                              },
                                              throwerror
                                          );
                                      },
                                      throwerror
                                  );
                              },
                              throwerror
                          );
                      },
                      throwerror
                  );
              },
              throwerror
          );
  
          jqd.when(d1).done(() => {
              callback();
          });
      }
  }
  
  var TestHelper = new TestHelperClass();
  export default TestHelper;
  