mirror of https://github.com/status-im/metro.git
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:
parent
356d896c01
commit
958a147162
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
jest.mock('../../node-haste/lib/toLocalPath');
|
jest.mock('../../node-haste/lib/toLocalPath');
|
||||||
jest.mock('../../Assets');
|
jest.mock('../../Assets');
|
||||||
jest.mock('../Serializers/RamBundle');
|
|
||||||
|
|
||||||
const {getAssetData} = require('../../Assets');
|
const {getAssetData} = require('../../Assets');
|
||||||
const toLocalPath = require('../../node-haste/lib/toLocalPath');
|
const toLocalPath = require('../../node-haste/lib/toLocalPath');
|
||||||
|
@ -26,7 +25,6 @@ describe('Serializers', () => {
|
||||||
const postProcessModules = jest.fn();
|
const postProcessModules = jest.fn();
|
||||||
let deltaBundler;
|
let deltaBundler;
|
||||||
let Serializers;
|
let Serializers;
|
||||||
let RamBundle;
|
|
||||||
|
|
||||||
const deltaResponse = {
|
const deltaResponse = {
|
||||||
id: '1234',
|
id: '1234',
|
||||||
|
@ -46,16 +44,9 @@ describe('Serializers', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
Serializers = require('../Serializers/Serializers');
|
Serializers = require('../Serializers/Serializers');
|
||||||
RamBundle = require('../Serializers/RamBundle');
|
|
||||||
|
|
||||||
getDelta.mockReturnValueOnce(Promise.resolve(deltaResponse));
|
getDelta.mockReturnValueOnce(Promise.resolve(deltaResponse));
|
||||||
getDependenciesFn.mockReturnValue(Promise.resolve(() => new Set()));
|
getDependenciesFn.mockReturnValue(Promise.resolve(() => new Set()));
|
||||||
RamBundle.getRamOptions.mockReturnValue(
|
|
||||||
Promise.resolve({
|
|
||||||
preloadedModules: {},
|
|
||||||
ramGroups: [],
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
postProcessModules.mockImplementation(modules => modules);
|
postProcessModules.mockImplementation(modules => modules);
|
||||||
|
|
||||||
deltaBundler = {
|
deltaBundler = {
|
||||||
|
@ -216,13 +207,6 @@ describe('Serializers', () => {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
RamBundle.getRamOptions.mockReturnValue(
|
|
||||||
Promise.resolve({
|
|
||||||
preloadedModules: {'/foo/3.js': true},
|
|
||||||
ramGroups: ['/foo/5.js'],
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
getDependenciesFn.mockReturnValue(
|
getDependenciesFn.mockReturnValue(
|
||||||
Promise.resolve(path => {
|
Promise.resolve(path => {
|
||||||
expect(path).toBe('/foo/5.js');
|
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(
|
expect(
|
||||||
await Serializers.getRamBundleInfo(deltaBundler, {}),
|
await Serializers.getRamBundleInfo(deltaBundler, {}, getTransformOptions),
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue