<commit_before>import {Graphite} from "../src";

describe('#logSnapshot', () => {
  it('logs a single snapshot power measurement', async () => {
    const snapshot = {
      createddate: '2018-02-23T16:15:44',
      power: 2661
    };
    const client = {
      write: jest.fn(),
    }; //{ write: stub.resolves({}) };
    client.write.mockReturnValue({});
    const config = {client: client};
    const graphite = new Graphite(config);
    await graphite.logSnapshot(snapshot);
    expect(client.write).toBeCalled();
    expect(client.write).toBeCalledWith({ eliq: { snapshot: { power: 2661 } } }, 1519398944000);
  });
});

describe('#log', () => {
  it('logs a bunch of measurements', async () => {
    const period = {
      startdate: '2015-02-12T00:00:00',
      enddate: '2015-02-13T00:00:00',
      intervaltype: 'hour',
      data:
        [{
          avgpower: 1710,
          energy: 1709,
          temp_out: 1,
          time_start: '2015-02-12T00:00:00',
          time_end: '2015-02-12T01:00:00'
        },
          {
            avgpower: 1820,
            energy: 1821,
            temp_out: 2,
            time_start: '2015-02-12T16:00:00',
            time_end: '2015-02-12T17:00:00'
          }]
    };
    const client = {write: jest.fn()};
    const config = {client: client};
    const graphite = new Graphite(config);

    await graphite.log(period);
    expect(client.write).toBeCalled();
    expect(client.write).toBeCalledWith({ eliq: { hour: { avgpower: 1710, energy: 1709 } } }, 1423697400000);
    expect(client.write).toBeCalledWith({ eliq: { hour: { avgpower: 1820, energy: 1821 } } }, 1423755000000);
  });
});<commit_msg>These tests fail in the npm publish workflow<commit_after>import {Graphite} from "../src";

describe('#logSnapshot', () => {
  it('logs a single snapshot power measurement', async () => {
    const snapshot = {
      createddate: '2018-02-23T16:15:44',
      power: 2661
    };
    const client = {
      write: jest.fn(),
    };
    client.write.mockReturnValue({});
    const config = {client: client};
    const graphite = new Graphite(config);
    await graphite.logSnapshot(snapshot);
    expect(client.write).toBeCalledWith({ eliq: { snapshot: { power: 2661 } } }, 1519398944000);
  });
});

describe('#log', () => {
  it('logs a bunch of measurements', async () => {
    const period = {
      startdate: '2015-02-12T00:00:00',
      enddate: '2015-02-13T00:00:00',
      intervaltype: 'hour',
      data:
        [{
          avgpower: 1710,
          energy: 1709,
          temp_out: 1,
          time_start: '2015-02-12T00:00:00',
          time_end: '2015-02-12T01:00:00'
        },
          {
            avgpower: 1820,
            energy: 1821,
            temp_out: 2,
            time_start: '2015-02-12T16:00:00',
            time_end: '2015-02-12T17:00:00'
          }]
    };
    const client = {write: jest.fn()};
    const config = {client: client};
    const graphite = new Graphite(config);

    await graphite.log(period);
    expect(client.write).toBeCalledWith({ eliq: { hour: { avgpower: 1710, energy: 1709 } } }, 1423697400000);
    expect(client.write).toBeCalledWith({ eliq: { hour: { avgpower: 1820, energy: 1821 } } }, 1423755000000);
  });
});
{'fraction_non_alphanumeric': 0.16414219474497682, 'fraction_numerical': 0.1106646058732612, 'mean_word_length': 2.4908306364617046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '7283582', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1074, 'n_words': 221}