<commit_before>goog.require('hutmap.templates');
goog.require('hutmap.Hut');

goog.require('goog.testing.jsunit');


setUp = function() {
  this.empty_hut = new hutmap.Hut();
  this.incomplete_hut = new hutmap.Hut({name: "The Hut", latlon: "47, -120"});
  this.complete_hut = new hutmap.Hut({
    id: 0,
    name: "<NAME>",
    country: "USA",
    state: "WA",
    agency: {name: "USDA Forest Service", url: "http://fs.usda.gov"},
    url: "http://hutwebsite.com",
    photo_url: "http://hutphoto.com",
    latlon: "47, -120",
    location_accuracy: 3
  });
};

/** hut_tooltip */
 
var test_hut_tooltip_null = function() {
  var error = false;
  try {
    hutmap.templates.hut_tooltip({hut: null});
  } catch (err) {
    error = true;
  }
  assertTrue(error);
};

var test_hut_tooltip_empty_hut = function() {
  var expected = '<div class="bold">Unknown Hut</div><div>Agency: unknown</div><div>Location accuracy: unknown</div>'
  var actual = hutmap.templates.hut_tooltip({hut: this.empty_hut});  
  assertEquals(expected, actual);
};

var test_hut_tooltip_incomplete_hut = function() {
  var expected = '<div class="bold">The Hut</div><div>Agency: unknown</div><div>Location accuracy: unknown</div>'
  var actual = hutmap.templates.hut_tooltip({hut: this.incomplete_hut});  
  assertEquals(expected, actual);
};

var test_hut_tooltip_complete_hut = function() {
  var expected = '<div class="bold">The Hut</div><div>Agency: USDA Forest Service</div><div>Location accuracy: 3</div>'
  var actual = hutmap.templates.hut_tooltip({hut: this.complete_hut}); 
  assertEquals(expected, actual);
};

/** hut_info */

var test_hut_info_null = function() {
  var error = false;
  try {
    hutmap.template.hut_info({hut: null});
  } catch (err) {
    error = true;
  }
  assertTrue(error);
};

var test_hut_info_empty_hut = function() {
  var actual = hutmap.templates.hut_info({hut: this.empty_hut});
  console.log(actual);
};

var test_hut_info_incomplete_hut = function() {
  var actual = hutmap.templates.hut_info({hut: this.incomplete_hut});
  console.log(actual);
};

var test_hut_info_complete_hut = function() {
  var expected = '<h4 id="sidebar_title">The Hut</h3><span class="hut_detail_table"><div id="sidebar_img"><a href="http://hutwebsite.com" target="blank"><img src="http://hutphoto.com" alt="Broken photo link!"></img></a></div><table><tr><td class="hut_detail_title">Country:</td><td class="hut_detail">USA</td></tr><tr><td class="hut_detail_title">State:</td><td class="hut_detail">WA</td></tr><tr><td class="hut_detail_title">Location:</td><td class="hut_detail">47, -120</td></tr><tr><td class="hut_detail_title">Accuracy:</td><td class="hut_detail">3</td></tr><tr><td class="hut_detail_title">Agency:</td><td class="hut_detail"><a href="http://fs.usda.gov">USDA Forest Service</a></td></tr><tr><td class="hut_detail_title">Hut Url:</td><td class="hut_detail"><a href="http://hutwebsite.com">http://hutwebsite...</a></td></tr></table>'
  var actual = hutmap.templates.hut_info({hut: this.complete_hut});
  assertEquals(expected, actual);
};<commit_msg>Updated tests to reflect newest field names and expected html.<commit_after>goog.require('hutmap.templates');
goog.require('hutmap.Hut');
goog.require('hutmap.Agency');
goog.require('hutmap.Region');

goog.require('goog.testing.jsunit');


setUp = function() {
  this.empty_hut = new hutmap.Hut();
  this.incomplete_hut = new hutmap.Hut({name: "The Hut", location: "47, -120"});
  this.complete_hut = new hutmap.Hut({
    id: 0,
    name: "<NAME>",
    agency: new hutmap.Agency({name: "USDA Forest Service", url: "http://fs.usda.gov"}),
    region: new hutmap.Region({country: "USA", state: "WA"}),
    hut_url: "http://hutwebsite.com",
    photo_url: "http://hutphoto.com",
    location: "47, -120",
    location_accuracy: 3
  });
};

/** hut_tooltip */
 
var test_hut_tooltip_null = function() {
  var error = false;
  try {
    hutmap.templates.hut_tooltip({hut: null});
  } catch (err) {
    error = true;
  }
  assertTrue(error);
};

var test_hut_tooltip_empty_hut = function() {
  var expected = '<div class="bold">unknown</div><div>Agency: unknown</div><div>Location accuracy: unknown</div>'
  var actual = hutmap.templates.hut_tooltip({hut: this.empty_hut});  
  assertEquals(expected, actual);
};

var test_hut_tooltip_incomplete_hut = function() {
  var expected = '<div class="bold">The Hut</div><div>Agency: unknown</div><div>Location accuracy: unknown</div>'
  var actual = hutmap.templates.hut_tooltip({hut: this.incomplete_hut});  
  assertEquals(expected, actual);
};

var test_hut_tooltip_complete_hut = function() {
  var expected = '<div class="bold">The Hut</div><div>Agency: USDA Forest Service</div><div>Location accuracy: 3</div>'
  var actual = hutmap.templates.hut_tooltip({hut: this.complete_hut}); 
  assertEquals(expected, actual);
};

/** hut_info */

var test_hut_info_null = function() {
  var error = false;
  try {
    hutmap.template.hut_info({hut: null});
  } catch (err) {
    error = true;
  }
  assertTrue(error);
};

var test_hut_info_empty_hut = function() {
  var actual = hutmap.templates.hut_info({hut: this.empty_hut});
};

var test_hut_info_incomplete_hut = function() {
  var actual = hutmap.templates.hut_info({hut: this.incomplete_hut});
};

var test_hut_info_complete_hut = function() {
  var expected = '<h4 id="sidebar_title">The Hut</h3><span class="hut_detail_table"><div id="sidebar_img"><a href="http://hutwebsite.com" target="blank"><img src="http://hutphoto.com" alt="Broken photo link!"></img></a></div><table><tr><td class="hut_detail_title">Country:</td><td class="hut_detail">USA</td></tr><tr><td class="hut_detail_title">State:</td><td class="hut_detail">WA</td></tr><tr><td class="hut_detail_title">Location:</td><td class="hut_detail">47, -120</td></tr><tr><td class="hut_detail_title">Accuracy:</td><td class="hut_detail">3</td></tr><tr><td class="hut_detail_title">Agency:</td><td class="hut_detail"><a href="http://fs.usda.gov" target="blank">USDA Forest Service</a></td></tr><tr><td class="hut_detail_title">Hut Url:</td><td class="hut_detail"><a href="http://hutwebsite.com" target="blank">http://hutwebsite...</a></td></tr></table>'
  var actual = hutmap.templates.hut_info({hut: this.complete_hut});
  console.log("actual: " + actual);
  assertEquals(expected, actual);
};
{'fraction_non_alphanumeric': 0.1933745443017911, 'fraction_numerical': 0.006657156443176415, 'mean_word_length': 5.518595041322314, 'pattern_counts': {'":': 0, '<': 143, '<?xml version=': 0, '>': 143, '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': '2348199', 'n_tokens_mistral': 2342, 'n_tokens_neox': 2258, 'n_words': 379}