Fix fresco tests

Summary:
The test used to exit before the promise was fulfilled, so essentially all tests passed. For more details, read [here](https://jestjs.io/docs/en/asynchronous.html)

> Be sure to return the assertion—if you omit this return statement, your test will complete before the promise returned from fetchData is resolved and then() has a chance to execute the callback.

Reviewed By: jknoxville

Differential Revision: D15804017

fbshipit-source-id: 769caa8957737b4864c5888d28854920e6a1447a
This commit is contained in:
Pritesh Nandgaonkar
2019-06-17 06:14:49 -07:00
committed by Facebook Github Bot
parent e5294d34f0
commit 347487a328

View File

@@ -81,7 +81,7 @@ test('the metric reducer for the input having regression', () => {
expect(FrescoPlugin.metricsReducer).toBeDefined();
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
const metrics = FrescoPlugin.metricsReducer(persistedState);
expect(metrics).resolves.toMatchObject({
return expect(metrics).resolves.toMatchObject({
WASTED_BYTES: 37500,
});
});
@@ -111,7 +111,7 @@ test('the metric reducer for the input having no regression', () => {
expect(metricsReducer).toBeDefined();
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
const metrics = metricsReducer(persistedState);
expect(metrics).resolves.toMatchObject({
return expect(metrics).resolves.toMatchObject({
WASTED_BYTES: 0,
});
});
@@ -121,7 +121,7 @@ test('the metric reducer for the default persisted state', () => {
expect(metricsReducer).toBeDefined();
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
const metrics = metricsReducer(FrescoPlugin.defaultPersistedState);
expect(metrics).resolves.toMatchObject({WASTED_BYTES: 0});
return expect(metrics).resolves.toMatchObject({WASTED_BYTES: 0});
});
test('the metric reducer with the events data but with no imageData in imagesMap ', () => {
@@ -150,7 +150,7 @@ test('the metric reducer with the events data but with no imageData in imagesMap
expect(metricsReducer).toBeDefined();
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
const metrics = metricsReducer(persistedState);
expect(metrics).resolves.toMatchObject({WASTED_BYTES: 0});
return expect(metrics).resolves.toMatchObject({WASTED_BYTES: 0});
});
test('the metric reducer with the no viewPort data in events', () => {
@@ -179,7 +179,7 @@ test('the metric reducer with the no viewPort data in events', () => {
expect(metricsReducer).toBeDefined();
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
const metrics = metricsReducer(persistedState);
expect(metrics).resolves.toMatchObject({WASTED_BYTES: 0});
return expect(metrics).resolves.toMatchObject({WASTED_BYTES: 0});
});
test('the metric reducer with the multiple events', () => {
@@ -245,7 +245,7 @@ test('the metric reducer with the multiple events', () => {
expect(metricsReducer).toBeDefined();
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
const metrics = metricsReducer(persistedState);
expect(metrics).resolves.toMatchObject({WASTED_BYTES: 172500});
return expect(metrics).resolves.toMatchObject({WASTED_BYTES: 160000});
});
test('closeable reference metrics on empty state', () => {
@@ -254,7 +254,7 @@ test('closeable reference metrics on empty state', () => {
) => Promise<MetricType> = (FrescoPlugin.metricsReducer: any);
const persistedState = mockPersistedState();
const metrics = metricsReducer(persistedState);
expect(metrics).resolves.toMatchObject({CLOSEABLE_REFERENCE_LEAKS: 0});
return expect(metrics).resolves.toMatchObject({CLOSEABLE_REFERENCE_LEAKS: 0});
});
test('closeable reference metrics on input', () => {
@@ -278,7 +278,7 @@ test('closeable reference metrics on input', () => {
closeableReferenceLeaks,
};
const metrics = metricsReducer(persistedState);
expect(metrics).resolves.toMatchObject({CLOSEABLE_REFERENCE_LEAKS: 2});
return expect(metrics).resolves.toMatchObject({CLOSEABLE_REFERENCE_LEAKS: 2});
});
test('notifications for leaks', () => {