<commit_before>// @flow

const updateResult = {
  matchedCount: 1,
  modifiedCount: 1,
};

const legacyResult = {
  result: {
    n: 1,
  }
};

const foundDoc = { field: 'cool doc' };
const cursor = { fetch: () => Promise.resolve([foundDoc]) };

const Collection = () => ({
  collectionName: 'coll',
  insertOne: jest.fn(doc => Promise.resolve({ ops: [doc] })),
  insertMany: jest.fn(docs => Promise.resolve({ ops: docs })),
  insert: jest.fn(docs => Promise.resolve({ ops: docs })),
  updateOne: jest.fn(() => Promise.resolve(updateResult)),
  updateMany: jest.fn(() => Promise.resolve(updateResult)),
  update: jest.fn(() => Promise.resolve(legacyResult)),
  deleteOne: jest.fn(() => Promise.resolve({ deletedCount: 1 })),
  deleteMany: jest.fn(() => Promise.resolve({ deletedCount: 1 })),
  remove: jest.fn(() => Promise.resolve(legacyResult)),
  find: jest.fn(() => cursor),
  findOne: jest.fn(() => Promise.resolve(foundDoc)),
});

const successJournaler = jest.fn(() => Promise.resolve());
const createSuccessJournaler = jest.fn(() => successJournaler);
const journalerError = new Error('Failure');
const failureJournaler = jest.fn(() => Promise.reject(journalerError));
const createFailureJournaler = jest.fn(() => failureJournaler);

jest.mock('fs');

import { auditCollection, fileJournaler } from '../src';

const configuredProxyCollection = auditCollection({
  journaler: createSuccessJournaler,
});

const collection = new Collection();

const user = {
  _id: 'the1',
  name: 'neo',<commit_msg>Changed mocked collection to use prototypical methods<commit_after>// @flow

import { auditCollection, fileJournaler } from '../src';

const updateResult = {
  matchedCount: 1,
  modifiedCount: 1,
};

const legacyResult = {
  result: {
    n: 1,
  }
};

const foundDoc = { field: 'cool doc' };
const cursor = { fetch: () => Promise.resolve([foundDoc]) };

const Collection = function () {
  this.collectionName = 'coll';
};

Object.assign(Collection.prototype, {
  insertOne: jest.fn(doc => Promise.resolve({ ops: [doc] })),
  insertMany: jest.fn(docs => Promise.resolve({ ops: docs })),
  insert: jest.fn(docs => Promise.resolve({ ops: docs })),
  updateOne: jest.fn(() => Promise.resolve(updateResult)),
  updateMany: jest.fn(() => Promise.resolve(updateResult)),
  update: jest.fn(() => Promise.resolve(legacyResult)),
  deleteOne: jest.fn(() => Promise.resolve({ deletedCount: 1 })),
  deleteMany: jest.fn(() => Promise.resolve({ deletedCount: 1 })),
  remove: jest.fn(() => Promise.resolve(legacyResult)),
  find: jest.fn(() => cursor),
  findOne: jest.fn(() => Promise.resolve(foundDoc)),
});

const successJournaler = jest.fn(() => Promise.resolve());
const createSuccessJournaler = jest.fn(() => successJournaler);
const journalerError = new Error('Failure');
const failureJournaler = jest.fn(() => Promise.reject(journalerError));
const createFailureJournaler = jest.fn(() => failureJournaler);

jest.mock('fs');

const configuredProxyCollection = auditCollection({
  journaler: createSuccessJournaler,
});

const collection = new Collection();

const user = {
  _id: 'the1',
  name: 'neo',
{'fraction_non_alphanumeric': 0.18389694041867954, 'fraction_numerical': 0.003864734299516908, 'mean_word_length': 5.078277886497065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 36, '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': '496890', 'n_tokens_mistral': 956, 'n_tokens_neox': 935, 'n_words': 227}