<commit_before>'use strict';
var test = require('tape');
var sinon = require('sinon');
require('sinon-as-promised');

var message = require('../../../app/scripts/webrtc/message');

/**
 * Manipulating the object directly leads to polluting the require cache. Any
 * test that modifies the required object should call this method to get a
 * fresh version
 */
function resetMessage() {
  delete require.cache[
    require.resolve('../../../app/scripts/webrtc/message')
  ];
  message = require('../../../app/scripts/webrtc/message');
}

test('creates correctly with legal args', function(t) {
  var typeList = 'list';
  var typeFile = 'file'; 
  var channelName = 'channel_123';

  message.createChannelName = sinon.stub().returns(channelName);

  var msg = new message.createMessage(typeList);

  t.equal(msg.type, typeList);
  t.equal(msg.channelName, channelName);

  var msg = new message.createMessage(typeFile);
  t.equal(msg.type, typeFile);

  resetMessage();
  t.end();
});

test('createMessage throws with invalid type', function(t) {
  var invalid = function() {
    new message.createMessage('fake-type');
  };<commit_msg>Fix typo<commit_after>'use strict';
var test = require('tape');
var sinon = require('sinon');
require('sinon-as-promised');

var message = require('../../../app/scripts/webrtc/message');

/**
 * Manipulating the object directly leads to polluting the require cache. Any
 * test that modifies the required object should call this method to get a
 * fresh version
 */
function resetMessage() {
  delete require.cache[
    require.resolve('../../../app/scripts/webrtc/message')
  ];
  message = require('../../../app/scripts/webrtc/message');
}

test('creates correctly with legal args', function(t) {
  var typeList = 'list';
  var typeFile = 'file'; 
  var channelName = 'channel_123';

  message.createChannelName = sinon.stub().returns(channelName);

  var msg = new message.createMessage(typeList);

  t.equal(msg.type, typeList);
  t.equal(msg.channelName, channelName);

  msg = new message.createMessage(typeFile);
  t.equal(msg.type, typeFile);

  resetMessage();
  t.end();
});

test('createMessage throws with invalid type', function(t) {
  var invalid = function() {
    new message.createMessage('fake-type');
  };
{'fraction_non_alphanumeric': 0.16038989809481613, 'fraction_numerical': 0.002658396101019052, 'mean_word_length': 4.051454138702461, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3097609', 'n_tokens_mistral': 698, 'n_tokens_neox': 681, 'n_words': 178}