<commit_before>/* global chai */

var React = require('react');
var TestUtils = require('react/lib/ReactTestUtils');
var expect = chai.expect;

var Message = require('../../../../app/components/messages/message');

describe('Message', function () {
  var timePrefs = {
    timezoneAware: true,
    timezoneName: 'Pacific/Honolulu'
  };

  describe('getInitialState', function() {
    it('should return an object with editing set to false', function() {
      console.warn = sinon.spy();
      var note = {
        timestamp : new Date().toISOString(),
        messagetext : 'foo',
        user : {
          fullName:'<NAME>'
        }
      };

      var elem = TestUtils.renderIntoDocument(<Message theNote={note} timePrefs={timePrefs} />);
      expect(elem).to.be.ok;

      var initialState = elem.getInitialState();
      console.log(initialState);
      expect(Object.keys(initialState).length).to.equal(1);
      expect(initialState.editing).to.equal(false);
      expect(console.warn.callCount).to.equal(0);
    });
  });

  describe('render', function() {
    it('should console.warn when required props are missing', function () {
      console.warn = sinon.spy();
      var elem = TestUtils.renderIntoDocument(<Message />);

      expect(console.warn.calledWith('Warning: Required prop `theNote` was not specified in `Message`.')).to.equal(true);
      expect(console.warn.calledWith('Warning: Required prop `timePrefs` was not specified in `Message`.')).to.equal(true);
      expect(console.warn.callCount).to.equal(2);
    });

    it('should render a populated message', function() {
      console.warn = sinon.spy();<commit_msg>Remove console.log from test<commit_after>/* global chai */

var React = require('react');
var TestUtils = require('react/lib/ReactTestUtils');
var expect = chai.expect;

var Message = require('../../../../app/components/messages/message');

describe('Message', function () {
  var timePrefs = {
    timezoneAware: true,
    timezoneName: 'Pacific/Honolulu'
  };

  describe('getInitialState', function() {
    it('should return an object with editing set to false', function() {
      console.warn = sinon.spy();
      var note = {
        timestamp : new Date().toISOString(),
        messagetext : 'foo',
        user : {
          fullName:'<NAME>'
        }
      };

      var elem = TestUtils.renderIntoDocument(<Message theNote={note} timePrefs={timePrefs} />);
      expect(elem).to.be.ok;

      var initialState = elem.getInitialState();
      expect(Object.keys(initialState).length).to.equal(1);
      expect(initialState.editing).to.equal(false);
      expect(console.warn.callCount).to.equal(0);
    });
  });

  describe('render', function() {
    it('should console.warn when required props are missing', function () {
      console.warn = sinon.spy();
      var elem = TestUtils.renderIntoDocument(<Message />);

      expect(console.warn.calledWith('Warning: Required prop `theNote` was not specified in `Message`.')).to.equal(true);
      expect(console.warn.calledWith('Warning: Required prop `timePrefs` was not specified in `Message`.')).to.equal(true);
      expect(console.warn.callCount).to.equal(2);
    });

    it('should render a populated message', function() {
      console.warn = sinon.spy();
{'fraction_non_alphanumeric': 0.1581039755351682, 'fraction_numerical': 0.001834862385321101, 'mean_word_length': 3.2870249017038007, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3945671', 'n_tokens_mistral': 973, 'n_tokens_neox': 952, 'n_words': 203}