<commit_before>'use strict';

import React from 'react/addons';
import $ from 'test/helpers/clockette-utils.jsx';


describe('Timezone', function() {
  var Timezone, expected, now;

  beforeEach(function() {
    Timezone = require('components/Timezone.jsx');
    now = new Date();

    expected = (function(now) {
      var hours = now.getHours(),
        minutes = now.getMinutes(),
        h, mm, A;

      h = hours > 12 ? (hours - 12) : hours;
      mm = minutes < 10 ? ('0' + minutes) : minutes;
      A = (hours < 12 || hours === 24) ? 'AM' : 'PM';

      return `${h}:${mm} ${A}`;
    })(now);
  });


  it('should output a formatted timezone without arguments', function() {
    var $component = $(
      <Timezone>
        <span>h:mm A</span>
      </Timezone>
    );

    expect($component.find('span').innerText).toBe(expected);
  });


  it('should output a formatted timezone with custom zone', function() {
    var $component = $(
      <Timezone zone="America/Los_Angeles">
        <span>h:mm A</span>
      </Timezone>
    );

    expect($component.find('span').innerText).toBe(expected);
  });


  it('should output a formatted timezone with custom offset', function() {
    var $component = $(
      <Timezone offset="420">
        <span>h:mm A</span>
      </Timezone>
    );

    expect($component.find('span').innerText).toBe(expected);
  });


  it('should output a formatted timezone with custom timestamp and zone', function() {
    var $component = $(
      <Timezone ts="1430741520000" zone="America/Los_Angeles">
        <span>h:mm A</span>
      </Timezone>
    );

    expect($component.find('span').innerText).toBe('5:12 AM');
  });


  it('should output a formatted timezone with custom timestamp and offset', function() {
    var $component = $(
      <Timezone ts="1430741520000" offset="420">
        <span>h:mm A</span>
      </Timezone>
    );

    expect($component.find('span').innerText).toBe('5:12 AM');
  });


  it('should output a formatted timezone in a nested node', function() {
    var $component = $(
      <Timezone>
        <div>
          <span>h:mm A</span>
          <span>YYYY</span>
        </div>
      </Timezone>
    );

    expect($component.find('span')[0].innerText).toBe(expected);
    expect($component.find('span')[1].innerText).toBe(String(now.getFullYear()));
  });

});
<commit_msg>Fix testcase output example for midnight (should be 12:00 AM and not 0:00 AM)<commit_after>'use strict';

import React from 'react/addons';
import $ from 'test/helpers/clockette-utils.jsx';


describe('Timezone', function() {
  var Timezone, expected, now;

  beforeEach(function() {
    Timezone = require('components/Timezone.jsx');
    now = new Date();

    expected = (function(now) {
      var hours = now.getHours(),
        minutes = now.getMinutes(),
        h, mm, A;

      h = (hours === 0) ? 12 : (hours > 12) ? hours - 12 : hours;
      mm = (minutes < 10) ? '0' + minutes : minutes;
      A = (hours < 12 || hours === 24) ? 'AM' : 'PM';

      return `${h}:${mm} ${A}`;
    })(now);
  });


  it('should output a formatted timezone without arguments', function() {
    var $component = $(
      <Timezone>
        <span>h:mm A</span>
      </Timezone>
    );

    expect($component.find('span').innerText).toBe(expected);
  });


  it('should output a formatted timezone with custom zone', function() {
    var $component = $(
      <Timezone zone="America/Los_Angeles">
        <span>h:mm A</span>
      </Timezone>
    );

    expect($component.find('span').innerText).toBe(expected);
  });


  it('should output a formatted timezone with custom offset', function() {
    var $component = $(
      <Timezone offset="420">
        <span>h:mm A</span>
      </Timezone>
    );

    expect($component.find('span').innerText).toBe(expected);
  });


  it('should output a formatted timezone with custom timestamp and zone', function() {
    var $component = $(
      <Timezone ts="1430741520000" zone="America/Los_Angeles">
        <span>h:mm A</span>
      </Timezone>
    );

    expect($component.find('span').innerText).toBe('5:12 AM');
  });


  it('should output a formatted timezone with custom timestamp and offset', function() {
    var $component = $(
      <Timezone ts="1430741520000" offset="420">
        <span>h:mm A</span>
      </Timezone>
    );

    expect($component.find('span').innerText).toBe('5:12 AM');
  });


  it('should output a formatted timezone in a nested node', function() {
    var $component = $(
      <Timezone>
        <div>
          <span>h:mm A</span>
          <span>YYYY</span>
        </div>
      </Timezone>
    );

    expect($component.find('span')[0].innerText).toBe(expected);
    expect($component.find('span')[1].innerText).toBe(String(now.getFullYear()));
  });

});

{'fraction_non_alphanumeric': 0.17708551118544846, 'fraction_numerical': 0.023416265941877484, 'mean_word_length': 2.839486356340289, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 61, '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': '7573527', 'n_tokens_mistral': 1630, 'n_tokens_neox': 1496, 'n_words': 348}