<commit_before>import { expect } from 'chai';
import models, { Op } from '../server/models';
import * as utils from '../test/utils';

import * as tlib from '../server/lib/transactions';

describe('lib.transactions.test.js', () => {

  const startDate = new Date("2017-02-01");
  const endDate = new Date("2017-03-01");
  let transactions;

  const where = {
    createdAt: { [Op.gte]: startDate, [Op.lt]: endDate}
  };

  before(() => utils.loadDB("wwcode_test"));

  beforeEach('get transactions', () => models.Transaction.findAll({ where }).then(ts => {
    transactions = ts;
    expect(transactions.length).to.equal(40);
  }));

  it('exports transactions', (done) => {
    const csv = tlib.exportTransactions(transactions);
    const lines = csv.split('\n');
    expect(lines.length).to.equal(41);
    expect(lines[0].split('","').length).to.equal(12);
    done();
  });

});<commit_msg>chore(tests): remove binary dump dep from lib.transactions test<commit_after>/* Test utilities */
import { expect } from 'chai';
import * as utils from './utils';
import * as store from './features/support/stores';

/* Support code */
import models from '../server/models';

/* Code being tested */
import * as libtransactions from '../server/lib/transactions';

describe('lib.transactions.test.js', () => {

  beforeEach(utils.resetTestDB);

  it('exports transactions', async () => {
    // Given a host with a collective
    const currency = 'USD';
    const { collective } = await store.newCollectiveWithHost('apex', currency, currency, 10);
    const { userCollective } = await store.newUser('a new user');
    // And given some transactions
    await store.stripeConnectedAccount(collective.HostCollectiveId);
    await store.stripeOneTimeDonation({ userCollective, collective, currency, amount: 100 });
    await store.stripeOneTimeDonation({ userCollective, collective, currency, amount: 200 });
    await store.stripeOneTimeDonation({ userCollective, collective, currency, amount: 300 });
    await store.stripeOneTimeDonation({ userCollective, collective, currency, amount: 400 });
    await store.stripeOneTimeDonation({ userCollective, collective, currency, amount: 500 });
    const transactions = await models.Transaction.findAll({ where: { CollectiveId: collective.id } });
    expect(transactions.length).to.equal(5);
    // When the newly created transactions are exported
    const csv = libtransactions.exportTransactions(transactions);
    const lines = csv.split('\n');
    expect(lines.length).to.equal(6);
    expect(lines[0].split('","').length).to.equal(12);
  }); /* End of "exports transactions" */

}); /* End of "lib.transactions.test.js" */
{'fraction_non_alphanumeric': 0.16078136739293764, 'fraction_numerical': 0.0169045830202855, 'mean_word_length': 4.201171875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '6693514', 'n_tokens_mistral': 814, 'n_tokens_neox': 779, 'n_words': 195}