less mocks in `Serializer-test`

Summary: now that RAM bundle info building is an implementation detail, we make it part of the test rather than mocking it out.

Reviewed By: rafeca

Differential Revision: D7084580

fbshipit-source-id: edbb7b3d1aaca5513ea81d8d2c62b4b5c8e97756
This commit is contained in:
David Aurelio 2018-02-27 09:28:16 -08:00 committed by Facebook Github Bot
parent 356d896c01
commit 958a147162
1 changed files with 6 additions and 17 deletions

View File

@ -12,7 +12,6 @@
jest.mock('../../node-haste/lib/toLocalPath');
jest.mock('../../Assets');
jest.mock('../Serializers/RamBundle');
const {getAssetData} = require('../../Assets');
const toLocalPath = require('../../node-haste/lib/toLocalPath');
@ -26,7 +25,6 @@ describe('Serializers', () => {
const postProcessModules = jest.fn();
let deltaBundler;
let Serializers;
let RamBundle;
const deltaResponse = {
id: '1234',
@ -46,16 +44,9 @@ describe('Serializers', () => {
beforeEach(() => {
Serializers = require('../Serializers/Serializers');
RamBundle = require('../Serializers/RamBundle');
getDelta.mockReturnValueOnce(Promise.resolve(deltaResponse));
getDependenciesFn.mockReturnValue(Promise.resolve(() => new Set()));
RamBundle.getRamOptions.mockReturnValue(
Promise.resolve({
preloadedModules: {},
ramGroups: [],
}),
);
postProcessModules.mockImplementation(modules => modules);
deltaBundler = {
@ -216,13 +207,6 @@ describe('Serializers', () => {
}),
);
RamBundle.getRamOptions.mockReturnValue(
Promise.resolve({
preloadedModules: {'/foo/3.js': true},
ramGroups: ['/foo/5.js'],
}),
);
getDependenciesFn.mockReturnValue(
Promise.resolve(path => {
expect(path).toBe('/foo/5.js');
@ -231,8 +215,13 @@ describe('Serializers', () => {
}),
);
const getTransformOptions = async () => ({
preloadedModules: {'/foo/3.js': true},
ramGroups: ['/foo/5.js'],
});
expect(
await Serializers.getRamBundleInfo(deltaBundler, {}),
await Serializers.getRamBundleInfo(deltaBundler, {}, getTransformOptions),
).toMatchSnapshot();
});