<commit_before>const moment = require('moment-timezone');
const config = {
  feedbackApi: {
    baseUrl: 'http://api-baseurl.com/',
    apiKey: 'APIKEY123456789',
  },
};
const fakeTime = moment().tz('Europe/London').startOf('day');

describe('feedback api library', () => {
  beforeEach(() => {
    this.sandbox = sinon.sandbox.create();
    this.request = this.sandbox.stub();
    this.clock = this.sandbox.useFakeTimers(fakeTime.valueOf());

    this.feedbackApi = proxyquire(`${rootFolder}/lib/feedback-api`, {
      request: this.request,
      '../config/config': config,
    });
  });

  afterEach(() => {
    this.sandbox.restore();
  });

  describe('#send', () => {
    it('should return form data if api returns 201 status code', () => {
      const formData = {
        text: 'Some feedback text',
        pageId: 'http://some-url.com/',
      };

      this.request.yields(null, { statusCode: 201 }, formData);

      const send = this.feedbackApi.send(formData);

      this.request.should.have.been.calledWith({
        method: 'POST',
        uri: config.feedbackApi.baseUrl,<commit_msg>Fix feedback api unit test Fake time was being called on current date which now fails tests since the day it was written... :/<commit_after>const moment = require('moment-timezone');
const config = {
  feedbackApi: {
    baseUrl: 'http://api-baseurl.com/',
    apiKey: 'APIKEY123456789',
  },
};
const fakeTime = moment('2016-06-24').tz('Europe/London').startOf('day');

describe('feedback api library', () => {
  beforeEach(() => {
    this.sandbox = sinon.sandbox.create();
    this.request = this.sandbox.stub();
    this.clock = this.sandbox.useFakeTimers(fakeTime.valueOf());

    this.feedbackApi = proxyquire(`${rootFolder}/lib/feedback-api`, {
      request: this.request,
      '../config/config': config,
    });
  });

  afterEach(() => {
    this.sandbox.restore();
  });

  describe('#send', () => {
    it('should return form data if api returns 201 status code', () => {
      const formData = {
        text: 'Some feedback text',
        pageId: 'http://some-url.com/',
      };

      this.request.yields(null, { statusCode: 201 }, formData);

      const send = this.feedbackApi.send(formData);

      this.request.should.have.been.calledWith({
        method: 'POST',
        uri: config.feedbackApi.baseUrl,
{'fraction_non_alphanumeric': 0.17374517374517376, 'fraction_numerical': 0.016302016302016303, 'mean_word_length': 3.062717770034843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6514283', 'n_tokens_mistral': 780, 'n_tokens_neox': 714, 'n_words': 146}