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';
module.exports = function() {
return function() {};
};
module.exports = () => () => {};

View File

@ -13,11 +13,8 @@ jest.autoMockOff();
const Promise = require('promise');
jest
.mock('fs')
.mock('../../../Cache')
.mock('../../../Activity');
.mock('fs');
var Cache = require('../../../Cache');
var DependencyGraph = require('../index');
var fs = require('fs');
@ -51,6 +48,13 @@ describe('DependencyGraph', function() {
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 = {
assetExts: ['png', 'jpg'],
cache: new Cache(),

View File

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