Inline cache mock for DependencyGraph-test

Reviewed By: davidaurelio

Differential Revision: D2629211

fb-gh-sync-id: ade0bf4e486b58ecbc9a29eb3bdb61286eebb3d5
This commit is contained in:
Christoph Pojer 2015-11-09 13:32:49 -08:00 committed by facebook-github-bot-7
parent 44b051d98d
commit 666706b0da
3 changed files with 10 additions and 8 deletions

View File

@ -8,6 +8,4 @@
*/ */
'use strict'; 'use strict';
module.exports = function() { module.exports = () => () => {};
return function() {};
};

View File

@ -13,11 +13,8 @@ jest.autoMockOff();
const Promise = require('promise'); const Promise = require('promise');
jest jest
.mock('fs') .mock('fs');
.mock('../../../Cache')
.mock('../../../Activity');
var Cache = require('../../../Cache');
var DependencyGraph = require('../index'); var DependencyGraph = require('../index');
var fs = require('fs'); var fs = require('fs');
@ -51,6 +48,13 @@ describe('DependencyGraph', function() {
isWatchman: () => Promise.resolve(false), isWatchman: () => Promise.resolve(false),
}; };
const Cache = jest.genMockFn();
Cache.prototype.get = jest.genMockFn().mockImplementation(
(filepath, field, cb) => cb(filepath)
);
Cache.prototype.invalidate = jest.genMockFn();
Cache.prototype.end = jest.genMockFn();
defaults = { defaults = {
assetExts: ['png', 'jpg'], assetExts: ['png', 'jpg'],
cache: new Cache(), cache: new Cache(),

View File

@ -42,7 +42,7 @@ class DependencyGraph {
this._opts = { this._opts = {
activity: activity || defaultActivity, activity: activity || defaultActivity,
roots, roots,
ignoreFilePath: ignoreFilePath || () => {}, ignoreFilePath: ignoreFilePath || (() => {}),
fileWatcher, fileWatcher,
assetRoots_DEPRECATED: assetRoots_DEPRECATED || [], assetRoots_DEPRECATED: assetRoots_DEPRECATED || [],
assetExts, assetExts,