<commit_before>/**
 * Copyright 2013-2015, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *
 * @emails oncall+relay
 */

'use strict';

var RelayTestUtils = require('RelayTestUtils');
RelayTestUtils.unmockRelay();

var GraphQL = require('GraphQL');
var GraphQLRange = require('GraphQLRange');
var Relay = require('Relay');
var RelayRecordStore = require('RelayRecordStore');

var readRelayDiskCache = require('readRelayDiskCache');
var resolveImmediate = require('resolveImmediate');

describe('readRelayDiskCache', () => {
  var {getNode} = RelayTestUtils;

  function readDiskCache(
    queries,
    diskCacheData,
    records,
    cachedRecords,
    rootCallMap,
    cachedRootCallMap,
  ) {
    cachedRecords = cachedRecords || {};
    cachedRootCallMap = cachedRootCallMap || {};
    diskCacheData = diskCacheData || {};

    var store = new RelayRecordStore(
      {
        records: records || {},
        cachedRecords,
      },
      {
        rootCallMap: rootCallMap || {},
        cachedRootCallMap,
      }
    );

    var cacheManager = {
      readNode: jest.genMockFunction().mockImplementation((id, callback) => {
        resolveImmediate(() => {
          callback(undefined, diskCacheData[id]);
        });
      }),
      readRootCall: jest.genMockFunction().mockImplementation(
        (callName, callArg, callback) => {
          var rootKey = callName + '*' + callArg;
          resolveImmediate(() => {
            callback(undefined, diskCacheData[rootKey]);
          });
        }
      ),
    };<commit_msg>Fix master tests in Relay OSS, really<commit_after>/**
 * Copyright 2013-2015, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *
 * @emails oncall+relay
 */

'use strict';

var RelayTestUtils = require('RelayTestUtils');
RelayTestUtils.unmockRelay();

var GraphQL = require('GraphQL');
var GraphQLRange = require('GraphQLRange');
var Relay = require('Relay');
var RelayRecordStore = require('RelayRecordStore');

var readRelayDiskCache = require('readRelayDiskCache');

describe('readRelayDiskCache', () => {
  var {getNode} = RelayTestUtils;

  function readDiskCache(
    queries,
    diskCacheData,
    records,
    cachedRecords,
    rootCallMap,
    cachedRootCallMap,
  ) {
    cachedRecords = cachedRecords || {};
    cachedRootCallMap = cachedRootCallMap || {};
    diskCacheData = diskCacheData || {};

    var store = new RelayRecordStore(
      {
        records: records || {},
        cachedRecords,
      },
      {
        rootCallMap: rootCallMap || {},
        cachedRootCallMap,
      }
    );

    var cacheManager = {
      readNode: jest.genMockFunction().mockImplementation((id, callback) => {
        setTimeout(() => {
          callback(undefined, diskCacheData[id]);
        });
      }),
      readRootCall: jest.genMockFunction().mockImplementation(
        (callName, callArg, callback) => {
          var rootKey = callName + '*' + callArg;
          setTimeout(() => {
            callback(undefined, diskCacheData[rootKey]);
          });
        }
      ),
    };
{'fraction_non_alphanumeric': 0.11932144910868316, 'fraction_numerical': 0.004600345025876941, 'mean_word_length': 3.003452243958573, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7651544', 'n_tokens_mistral': 998, 'n_tokens_neox': 975, 'n_words': 245}