<commit_before>const html = require('choo/html');
const call = require('./call.js');
const chai = require('chai');
const expect = chai.expect;

describe('call component', () => {
  it('should return "No calls to make" if issue cannot be found', () => {
    let expectSubstr = 'No calls to make';
    let location = {params: {issueid: undefined}};
    let issues = [];
    let state = {issues, location};
    let result = call(state);
    // console.log('html: ', result.toString());
    expect(result.toString()).to.contain(expectSubstr);
  });

  it('should return contact information', () => {
    // For simplicity, we're setting up one issue and contact
    let expectSubstr = '<NAME>';
    let id = 1;
    let location = {params: {issueid: id}};
    let issue = {id: id, name: '<NAME>', reason: 'crazy', script: 'Please vote against everything'};
    let contact = {name: expectSubstr, party: 'Dem'};
    issue.contacts = [contact];
    let issues = [issue];
    let state = {issues, location, contactIndex: 0};
    let result = call(state);
    let el = result.toString();
    // console.log('html: ', el);
    expect(el).to.contain(expectSubstr);
  });
});<commit_msg>Added  tests; cleaned up others<commit_after>const html = require('choo/html');
const call = require('./call.js');
const chai = require('chai');
const expect = chai.expect;

describe('call component', () => {
  it('should return "No calls to make" if issue cannot be found', () => {
    let expectSubstr = 'No calls to make';
    let location = {params: {issueid: undefined}};
    let issues = [];
    let state = {issues, location};
    let result = call(state);
    // console.log('html: ', result.toString());
    expect(result.toString()).to.contain(expectSubstr);
  });

  describe('contact section', () => {

    it('should display contact if contact data is present in state', () => {
      let cname = '<NAME>';
      let id = 1;
      let location = {params: {issueid: id}};
      let issue = {id: id, name: '<NAME>', reason: 'crazy', script: 'Please vote against everything'};
      let contact = {name: cname, party: 'Dem'};
      issue.contacts = [contact];
      let issues = [issue];
      let state = {issues, location, contactIndex: 0};
      let result = call(state);
      let h3s = result.getElementsByTagName('h3');
      // First h3 should contain 'Call this office'
      expect(h3s[0].childNodes[0].data).to.contain('Call this office');
    });

    it('should display "no contact" message if no contact data is NOT present in state', () => {
      let id = 1;
      let location = {params: {issueid: id}};
      let issue = {id: id, name: '<NAME>', reason: 'crazy', script: 'Please vote against everything'};
      issue.contacts = [null];
      let issues = [issue];
      let state = {issues, location, contactIndex: 0};
      let result = call(state);
      let as = result.getElementsByTagName('a');
      // console.log('as children data', as[0].childNodes[0].data);
      // First h2 should contain 'to find your representatives'
      expect(as[0].childNodes[0].data).to.contain('Set your location');
    });
  });
});
{'fraction_non_alphanumeric': 0.1680537772087068, 'fraction_numerical': 0.005441741357234315, 'mean_word_length': 3.298486932599725, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 16, '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': '6699039', 'n_tokens_mistral': 948, 'n_tokens_neox': 937, 'n_words': 301}