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:
committed by
Facebook Github Bot
parent
e5294d34f0
commit
347487a328
@@ -81,7 +81,7 @@ test('the metric reducer for the input having regression', () => {
|
|||||||
expect(FrescoPlugin.metricsReducer).toBeDefined();
|
expect(FrescoPlugin.metricsReducer).toBeDefined();
|
||||||
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
||||||
const metrics = FrescoPlugin.metricsReducer(persistedState);
|
const metrics = FrescoPlugin.metricsReducer(persistedState);
|
||||||
expect(metrics).resolves.toMatchObject({
|
return expect(metrics).resolves.toMatchObject({
|
||||||
WASTED_BYTES: 37500,
|
WASTED_BYTES: 37500,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -111,7 +111,7 @@ test('the metric reducer for the input having no regression', () => {
|
|||||||
expect(metricsReducer).toBeDefined();
|
expect(metricsReducer).toBeDefined();
|
||||||
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
||||||
const metrics = metricsReducer(persistedState);
|
const metrics = metricsReducer(persistedState);
|
||||||
expect(metrics).resolves.toMatchObject({
|
return expect(metrics).resolves.toMatchObject({
|
||||||
WASTED_BYTES: 0,
|
WASTED_BYTES: 0,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -121,7 +121,7 @@ test('the metric reducer for the default persisted state', () => {
|
|||||||
expect(metricsReducer).toBeDefined();
|
expect(metricsReducer).toBeDefined();
|
||||||
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
||||||
const metrics = metricsReducer(FrescoPlugin.defaultPersistedState);
|
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 ', () => {
|
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();
|
expect(metricsReducer).toBeDefined();
|
||||||
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
||||||
const metrics = metricsReducer(persistedState);
|
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', () => {
|
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();
|
expect(metricsReducer).toBeDefined();
|
||||||
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
||||||
const metrics = metricsReducer(persistedState);
|
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', () => {
|
test('the metric reducer with the multiple events', () => {
|
||||||
@@ -245,7 +245,7 @@ test('the metric reducer with the multiple events', () => {
|
|||||||
expect(metricsReducer).toBeDefined();
|
expect(metricsReducer).toBeDefined();
|
||||||
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
//$FlowFixMe: Added a check if the metricsReducer exists in FrescoPlugin
|
||||||
const metrics = metricsReducer(persistedState);
|
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', () => {
|
test('closeable reference metrics on empty state', () => {
|
||||||
@@ -254,7 +254,7 @@ test('closeable reference metrics on empty state', () => {
|
|||||||
) => Promise<MetricType> = (FrescoPlugin.metricsReducer: any);
|
) => Promise<MetricType> = (FrescoPlugin.metricsReducer: any);
|
||||||
const persistedState = mockPersistedState();
|
const persistedState = mockPersistedState();
|
||||||
const metrics = metricsReducer(persistedState);
|
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', () => {
|
test('closeable reference metrics on input', () => {
|
||||||
@@ -278,7 +278,7 @@ test('closeable reference metrics on input', () => {
|
|||||||
closeableReferenceLeaks,
|
closeableReferenceLeaks,
|
||||||
};
|
};
|
||||||
const metrics = metricsReducer(persistedState);
|
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', () => {
|
test('notifications for leaks', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user