Skip to content

Commit

Permalink
fix(it): remove fetch mock from integration tests (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
TiagoGrosso authored Aug 8, 2024
1 parent 560100b commit e8ae3c3
Show file tree
Hide file tree
Showing 36 changed files with 34 additions and 3 deletions.
1 change: 0 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ const config: Config.InitialOptions = {
statements: 95,
},
},
setupFiles: ['./src/test/SetupJest.ts'],
};
export default config;
2 changes: 0 additions & 2 deletions src/test/SetupJest.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/test/requests/AbstractRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('AbstractRequest', () => {

const request: AbstractRequestImpl = new AbstractRequestImpl();

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify(TestConstants.FULL_MEDIA_DATA));
it('Executes the request', async () => {
const response = await request.execute();
Expand Down
1 change: 1 addition & 0 deletions src/test/requests/comment/DeleteCommentRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('DeleteCommentRequest', () => {
expect(request.config().url).toEqual(`/${TestConstants.COMMENT_ID}`);
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify({ success: true }));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
1 change: 1 addition & 0 deletions src/test/requests/comment/GetCommentRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('GetCommentRequest', () => {
expect(requestAllFields.config().params.fields).toEqual(Object.values(CommentField).join(','));
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify(TestConstants.COMMENTS_DATA[1]));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
1 change: 1 addition & 0 deletions src/test/requests/comment/PostHideCommentRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('PostHideCommentRequest', () => {
expect(requestExplicit.config().params.hide).toEqual(false);
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify({ success: true }));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('GetRepliesRequest', () => {
);
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: TestConstants.COMMENTS_DATA,
Expand Down
1 change: 1 addition & 0 deletions src/test/requests/comment/replies/PostReplyRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('GetRepliesRequest', () => {
expect(request.config().params.message).toEqual(TestConstants.COMMENT_TEXT);
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
id: TestConstants.COMMENT_ID,
Expand Down
1 change: 1 addition & 0 deletions src/test/requests/container/GetContainerRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('GetContainerRequest', () => {
expect(requestAllFields.config().params.fields).toEqual(Object.values(ContainerField).join(','));
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
id: TestConstants.CONTAINER_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('AbstractGetHashtagMediaRequest', () => {
expect(requestAllFields.config().params.fields).toEqual(Object.values(HashtagMediaField).join(','));
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: [TestConstants.HASHTAG_ALBUM_MEDIA_DATA, TestConstants.HASHTAG_IMAGE_MEDIA_DATA],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('GetHashtagIdRequest', () => {
expect(request.config().url).toEqual('/ig_hashtag_search');
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify({ data: [{ id: TestConstants.HASHTAG_ID }] }));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('GetMediaCommentsRequest', () => {
expect(request.config().url).toEqual(`/${TestConstants.MEDIA_ID}/children`);
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: TestConstants.CHILDREN_DATA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('GetMediaCommentsRequest', () => {
expect(requestAllFields.config().params.fields).toEqual(Object.values(CommentField).join(','));
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: TestConstants.COMMENTS_DATA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('GetMediaCommentsRequest', () => {
expect(request.config().url).toEqual(`/${TestConstants.MEDIA_ID}/comments`);
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
id: TestConstants.COMMENT_ID,
Expand Down
1 change: 1 addition & 0 deletions src/test/requests/media/info/GetMediaInfoRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('GetMediaInfoRequest', () => {
);
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify(TestConstants.PARTIAL_MEDIA_DATA));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('GetAlbumMediaInsightsRequest', () => {
expect(allFieldsRequest.config().params.metric).toEqual(Object.values(AlbumMetric).join(','));
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: TestConstants.SIMPLE_METRIC_DATA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('GetSimplePostMediaInsightsRequest', () => {
expect(allFieldsRequest.config().params.metric).toEqual(Object.values(SimplePostMetric).join(','));
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: TestConstants.SIMPLE_METRIC_DATA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('GetStoryMediaInsightsRequest', () => {
expect(allFieldsRequest.config().params.metric).toEqual(Object.values(StoryMetric).join(','));
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: TestConstants.SIMPLE_METRIC_DATA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('GetPageInfoRequest', () => {
expect(request.config().url).toEqual('/me/accounts');
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify(TestConstants.AUTHORIZED_FACEBOOK_PAGES));
it('Parses the response', async () => {
const response = await request.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('GetContentPublishingLimitRequest', () => {
);
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: [TestConstants.CONTENT_PUBLISHING_LIMIT_DATA],
Expand Down
1 change: 1 addition & 0 deletions src/test/requests/page/info/GetPageInfoRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('GetPageInfoRequest', () => {
expect(requestAllFields.config().params.fields).toEqual(Object.values(PageField).join(','));
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify(TestConstants.PAGE_INFO_DATA));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('AbstractGetPageInsightsRequest', () => {

const request: AbstractPageInsightsRequestImpl = new AbstractPageInsightsRequestImpl();

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: TestConstants.SIMPLE_METRIC_DATA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('GetPageLifetimeInsightsRequest', () => {
expect(allFieldsRequest.config().params.metric).toEqual(Object.values(LifetimeMetric).join(','));
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: TestConstants.COMPLEX_METRIC_DATA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('GetInstagramAccountInfoRequest', () => {
expect(request.config().url).toEqual(`/${TestConstants.INSTAGRAM_ID}`);
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify(TestConstants.INSTAGRAM_ACCOUNT_DATA));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('GetLinkedInstagramAccountRequest', () => {
expect(request.config().url).toEqual(`/${TestConstants.PAGE_ID}`);
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify(TestConstants.LINKED_INSTAGRAM_ACCOUNT));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
1 change: 1 addition & 0 deletions src/test/requests/page/media/GetPageMediaRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('GetPageMediaRequest', () => {
expect(requestAllFields.config().params.fields).toEqual(Utils.getAllMediaFields().join(','));
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: [TestConstants.PARTIAL_MEDIA_DATA],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe('PostPageCaroulselMediaRequest.', () => {
expect(request.config().params.children).toEqual(TestConstants.ID_ARRAY.slice(1));
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify({ id: TestConstants.CONTAINER_ID }));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('PostPagePhotoMediaRequest.', () => {
expect(requestBare.config().params.is_carousel).toBeTruthy();
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify({ id: TestConstants.CONTAINER_ID }));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('PostPageReelMediaRequest.', () => {
expect(request.config().params.share_to_feed).toEqual(TestConstants.SHARE_TO_FEED);
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify({ id: TestConstants.CONTAINER_ID }));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('PostPageStoriesVideoMediaRequest.', () => {
expect(request.config().params.video_url).toEqual(TestConstants.MEDIA_URL);
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify({ id: TestConstants.CONTAINER_ID }));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('PostPageStoriesPhotoMediaRequest.', () => {
expect(request.config().params.image_url).toEqual(TestConstants.MEDIA_URL);
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify({ id: TestConstants.CONTAINER_ID }));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('PostPublishMediaRequest', () => {
expect(request.config().params.creation_id).toEqual(TestConstants.CONTAINER_ID);
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
id: TestConstants.MEDIA_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('GetPageRecentlySearchedHashtagsRequest', () => {
expect(request.config().url).toEqual(`/${TestConstants.PAGE_ID}/recently_searched_hashtags`);
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: [{ id: TestConstants.HASHTAG_ID }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('GetPageStoriesRequest', () => {
expect(request.config().url).toEqual(`/${TestConstants.PAGE_ID}/stories`);
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: [{ id: TestConstants.MEDIA_ID }],
Expand Down
1 change: 1 addition & 0 deletions src/test/requests/page/tags/GetTagsRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('GetTagsRequest', () => {
);
});

fetchMock.enableMocks();
fetchMock.mockOnce(
JSON.stringify({
data: [TestConstants.PARTIAL_MEDIA_DATA],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('GetUserLongLivedTokenRequest', () => {
expect(request.config().url).toEqual(buildUrl());
});

fetchMock.enableMocks();
fetchMock.mockOnce(JSON.stringify(TestConstants.USER_LONG_LIVED_TOKEN_DATA));
it('Parses the response', async () => {
expect.assertions(1);
Expand Down

0 comments on commit e8ae3c3

Please sign in to comment.