mirror of
https://github.com/strapi/strapi.git
synced 2025-07-25 09:56:53 +00:00
test(metrics): mock strapi fetch function
This commit is contained in:
parent
50a2e58dda
commit
eda33f812d
@ -3,10 +3,14 @@
|
|||||||
jest.mock('node-fetch', () => jest.fn(() => Promise.resolve()));
|
jest.mock('node-fetch', () => jest.fn(() => Promise.resolve()));
|
||||||
|
|
||||||
const { get } = require('lodash/fp');
|
const { get } = require('lodash/fp');
|
||||||
const fetch = require('node-fetch');
|
|
||||||
const metrics = require('../index');
|
const metrics = require('../index');
|
||||||
|
|
||||||
|
const fetch = jest.fn(() => Promise.resolve());
|
||||||
|
|
||||||
describe('metrics', () => {
|
describe('metrics', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
fetch.mockClear();
|
||||||
|
});
|
||||||
test('Initializes a middleware', () => {
|
test('Initializes a middleware', () => {
|
||||||
const use = jest.fn();
|
const use = jest.fn();
|
||||||
|
|
||||||
@ -32,6 +36,7 @@ describe('metrics', () => {
|
|||||||
requestContext: {
|
requestContext: {
|
||||||
get: jest.fn(() => ({})),
|
get: jest.fn(() => ({})),
|
||||||
},
|
},
|
||||||
|
fetch,
|
||||||
});
|
});
|
||||||
|
|
||||||
metricsInstance.register();
|
metricsInstance.register();
|
||||||
@ -66,6 +71,7 @@ describe('metrics', () => {
|
|||||||
requestContext: {
|
requestContext: {
|
||||||
get: jest.fn(() => ({})),
|
get: jest.fn(() => ({})),
|
||||||
},
|
},
|
||||||
|
fetch,
|
||||||
});
|
});
|
||||||
|
|
||||||
metricsInstance.register();
|
metricsInstance.register();
|
||||||
@ -98,6 +104,7 @@ describe('metrics', () => {
|
|||||||
requestContext: {
|
requestContext: {
|
||||||
get: jest.fn(() => ({})),
|
get: jest.fn(() => ({})),
|
||||||
},
|
},
|
||||||
|
fetch,
|
||||||
});
|
});
|
||||||
|
|
||||||
send('someEvent');
|
send('someEvent');
|
||||||
@ -140,6 +147,7 @@ describe('metrics', () => {
|
|||||||
requestContext: {
|
requestContext: {
|
||||||
get: jest.fn(() => ({})),
|
get: jest.fn(() => ({})),
|
||||||
},
|
},
|
||||||
|
fetch,
|
||||||
});
|
});
|
||||||
|
|
||||||
send('someEvent');
|
send('someEvent');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user