<commit_before>/*globals describe, it*/

var should = require("should");
describe("Hours", function(){
  var Hours = require('../js/app/models/hours'),
      hours = new Hours({
        Sun: "9AM-6PM",
        Mon: "9AM-12PM,2PM-5PM",
        Tue: "9AM-6PM",
        Wed: "9AM-6PM",
        Thu: "9AM-6PM",
        Fri: "9AM-6PM",
        Sat: "9AM-6PM"
      });

  describe("creating", function() {
    it("should convert text times to offsets", function() {
      hours.hours.should.eql({
        0: [[900,1800]],
        1: [[900,1200], [1400,1700]],
        2: [[900,1800]],
        3: [[900,1800]],
        4: [[900,1800]],
        5: [[900,1800]],
        6: [[900,1800]]
      });
    });

    it("should catch bad input", function() {
      (function() { hours.addDay("Mon", ""); }).should.throwError(/Invalid time/);
      (function() { hours.addDay("Mon", "4pm"); }).should.throwError(/Invalid time/);
      (function() { hours.addDay("Mon", "abcd"); }).should.throwError(/Invalid time/);
      (function() { hours.addDay("Mon", "9PM-10PMgarbage"); }).should.throwError(/Invalid time/);

      (function() { hours.addDay("Mon", "9PM-9PM"); }).should.throwError(/Invalid time/);

      (function() { hours.addDay("Mon", "9PM-9AM"); }).should.throwError(/Invalid time/);

    });
  });

  describe("#within", function(){
    it("should work with strings", function() {
      hours.within("Sun,10:30AM").should.equal(true);
      hours.within("Mon,10:30AM").should.equal(true);
      hours.within("Mon,12:30PM").should.equal(false);
    });

    it("should work with dates", function() {
      hours.within(new Date(2013, 3, 7, 10, 30)).should.equal(true);
      hours.within(new Date(2013, 3, 1, 10, 30)).should.equal(true);
      hours.within(new Date(2013, 3, 1, 12, 30)).should.equal(false);
    });

  });

  describe("#isEmpty", function() {
    it("should usually say no", function() { 
      hours.isEmpty().should.equal(false);
    });

    it("should say yes if hours has no keys", function() { 
      new Hours().isEmpty().should.equal(true);
    });
  });
});<commit_msg>hours: added tests for addDay<commit_after>/*globals describe, it, beforeEach*/

var should = require("should");
describe("Hours", function(){
  var Hours = require('../js/app/models/hours'),
      hours;
  describe("creating", function() {
    beforeEach(function() {
      hours = new Hours({
        Sun: "9AM-6PM",
        Mon: "9AM-12PM,2PM-5PM",
        Tue: "9AM-6PM",
        Wed: "9AM-6PM",
        Thu: "9AM-6PM",
        Fri: "9AM-6PM",
        Sat: "9AM-6PM"
      });
    });

    it("should convert text times to offsets", function() {
      hours.hours.should.eql({
        0: [[900,1800]],
        1: [[900,1200], [1400,1700]],
        2: [[900,1800]],
        3: [[900,1800]],
        4: [[900,1800]],
        5: [[900,1800]],
        6: [[900,1800]]
      });
    });

    it("should catch bad input", function() {
      (function() { hours.addDay("Mon", ""); }).should.throwError(/Invalid time/);
      (function() { hours.addDay("Mon", "4pm"); }).should.throwError(/Invalid time/);
      (function() { hours.addDay("Mon", "abcd"); }).should.throwError(/Invalid time/);
      (function() { hours.addDay("Mon", "9PM-10PMgarbage"); }).should.throwError(/Invalid time/);

      (function() { hours.addDay("Mon", "9PM-9PM"); }).should.throwError(/Invalid time/);

      (function() { hours.addDay("Mon", "9PM-9AM"); }).should.throwError(/Invalid time/);

    });
  });

  describe("#addDay", function() {
    beforeEach(function() {
      hours = new Hours();
    });

    it("should add open hours per day", function() {
      hours.addDay("Sun", "9AM-6PM");
      hours.addDay("Mon", "9AM-12PM,2PM-5PM");
      hours.addDay("Tue", "9AM-6PM");
      hours.addDay("Wed", "9AM-6PM");
      hours.addDay("Thu", "9AM-6PM");
      hours.addDay("Fri", "9AM-6PM");
      hours.addDay("Sat", "9AM-6PM");

      hours.hours.should.eql({
        0: [[900,1800]],
        1: [[900,1200], [1400,1700]],
        2: [[900,1800]],
        3: [[900,1800]],
        4: [[900,1800]],
        5: [[900,1800]],
        6: [[900,1800]]
      });

    });

  });

  describe("#within", function(){
    it("should work with strings", function() {
      hours.within("Sun,10:30AM").should.equal(true);
      hours.within("Mon,10:30AM").should.equal(true);
      hours.within("Mon,12:30PM").should.equal(false);
    });

    it("should work with dates", function() {
      hours.within(new Date(2013, 3, 7, 10, 30)).should.equal(true);
      hours.within(new Date(2013, 3, 1, 10, 30)).should.equal(true);
      hours.within(new Date(2013, 3, 1, 12, 30)).should.equal(false);
    });

  });

  describe("#isEmpty", function() {
    it("should usually say no", function() { 
      hours.isEmpty().should.equal(false);
    });

    it("should say yes if hours has no keys", function() { 
      new Hours().isEmpty().should.equal(true);
    });
  });
});
{'fraction_non_alphanumeric': 0.2222222222222222, 'fraction_numerical': 0.06954582319545823, 'mean_word_length': 2.7599085365853657, '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': '1503790', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1648, 'n_words': 328}