<commit_before>const sinon = require('sinon');

class MockResource {
  constructor() {
    this.getCollection = sinon.stub();
    this.getModel = sinon.stub();
    this.__resetMocks = this.__resetMocks.bind(this);
    this.__getCollectionFetchReturns = this.__getCollectionFetchReturns.bind(this);
    this.__getModelFetchReturns = this.__getModelFetchReturns.bind(this);
  }

  __resetMocks() {
    this.getCollection.reset();
    this.getModel.reset();
  }

  __getFetchable(payload, willReject = false) {
    const fetchable = {};
    if (willReject) {
      fetchable.fetch = () => Promise.reject(payload);
    } else {
      fetchable.fetch = () => Promise.resolve(payload);
    }
    return fetchable;
  }
  __getModelFetchReturns(payload, willReject = false) {
    this.getModel.returns(this.__getFetchable(payload, willReject));
  }

  __getCollectionFetchReturns(payload, willReject = false) {
    this.getCollection.returns(this.__getFetchable(payload, willReject));
  }
}

class KolibriMock {
  constructor() {
    this.resources = {<commit_msg>Add savable config for mocks<commit_after>const sinon = require('sinon');

class MockResource {
  constructor() {
    this.getCollection = sinon.stub();
    this.getModel = sinon.stub();
    this.__resetMocks = this.__resetMocks.bind(this);
    this.__getCollectionFetchReturns = this.__getCollectionFetchReturns.bind(this);
    this.__getModelFetchReturns = this.__getModelFetchReturns.bind(this);
  }

  __resetMocks() {
    this.getCollection.reset();
    this.getModel.reset();
  }

  __getFetchable(payload, willReject = false) {
    const fetchable = {};
    if (willReject) {
      fetchable.fetch = () => Promise.reject(payload);
    } else {
      fetchable.fetch = () => Promise.resolve(payload);
    }
    return fetchable;
  }

  __getSavable(payload, willReject = false) {
    const fetchable = {};
    if (willReject) {
      fetchable.save = () => Promise.reject(payload);
    } else {
      fetchable.save = () => Promise.resolve(payload);
    }
    return fetchable;
  }

  __getModelFetchReturns(payload, willReject = false) {
    this.getModel.returns(this.__getFetchable(payload, willReject));
  }

  __getModelSaveReturns(payload, willReject = false) {
    this.getModel.returns(this.__getSavable(payload, willReject));
  }

  __getCollectionFetchReturns(payload, willReject = false) {
    this.getCollection.returns(this.__getFetchable(payload, willReject));
  }
}

class KolibriMock {
  constructor() {
    this.resources = {
{'fraction_non_alphanumeric': 0.12939297124600638, 'fraction_numerical': 0.0, 'mean_word_length': 3.854651162790698, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '501926', 'n_tokens_mistral': 788, 'n_tokens_neox': 780, 'n_words': 117}