reduce needless use of jest-fetch-mock
flag=none Change-Id: Ia630b92364a2dd211077c6be910aff676a2f03d3 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/337038 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Spencer Olson <solson@instructure.com> QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com> Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
This commit is contained in:
parent
02ba542855
commit
d6c61ed2ee
|
@ -23,9 +23,6 @@ import {RequestDispatch} from '@canvas/network'
|
|||
import PerformanceControls from '../../PerformanceControls'
|
||||
import FakeServer from '@canvas/network/NaiveRequestDispatch/__tests__/FakeServer'
|
||||
import {NetworkFake} from '@canvas/network/NetworkFake/index'
|
||||
import {enableFetchMocks} from 'jest-fetch-mock'
|
||||
|
||||
enableFetchMocks()
|
||||
|
||||
const initialState = store.getState()
|
||||
|
||||
|
|
|
@ -23,14 +23,9 @@ import {ApolloProvider} from 'react-apollo'
|
|||
import {handlers} from '../../../../graphql/mswHandlers'
|
||||
import {mswClient} from '../../../../../../shared/msw/mswClient'
|
||||
import {mswServer} from '../../../../../../shared/msw/mswServer'
|
||||
import {enableFetchMocks} from 'jest-fetch-mock'
|
||||
|
||||
enableFetchMocks()
|
||||
|
||||
const server = mswServer(handlers)
|
||||
beforeAll(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.dontMock()
|
||||
server.listen()
|
||||
})
|
||||
|
||||
|
@ -40,8 +35,6 @@ afterEach(() => {
|
|||
|
||||
afterAll(() => {
|
||||
server.close()
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.enableMocks()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -27,9 +27,6 @@ import {mswServer} from '../../../../../../shared/msw/mswServer'
|
|||
import {handlers} from '../../../../graphql/mswHandlers'
|
||||
import {mswClient} from '../../../../../../shared/msw/mswClient'
|
||||
import {ApolloProvider} from 'react-apollo'
|
||||
import {enableFetchMocks} from 'jest-fetch-mock'
|
||||
|
||||
enableFetchMocks()
|
||||
|
||||
jest.mock('../../../../util/utils', () => ({
|
||||
...jest.requireActual('../../../../util/utils'),
|
||||
|
@ -60,8 +57,6 @@ describe('HeaderInputs', () => {
|
|||
})
|
||||
|
||||
beforeAll(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.dontMock()
|
||||
server.listen()
|
||||
|
||||
window.matchMedia = jest.fn().mockImplementation(() => {
|
||||
|
@ -94,8 +89,6 @@ describe('HeaderInputs', () => {
|
|||
})
|
||||
|
||||
afterAll(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.enableMocks()
|
||||
server.close()
|
||||
})
|
||||
|
||||
|
|
|
@ -31,9 +31,6 @@ import {
|
|||
ConversationContext,
|
||||
CONVERSATION_ID_WHERE_CAN_REPLY_IS_FALSE,
|
||||
} from '../../../../util/constants'
|
||||
import {enableFetchMocks} from 'jest-fetch-mock'
|
||||
|
||||
enableFetchMocks()
|
||||
|
||||
jest.mock('../../../../util/utils', () => ({
|
||||
...jest.requireActual('../../../../util/utils'),
|
||||
|
@ -42,8 +39,6 @@ jest.mock('../../../../util/utils', () => ({
|
|||
describe('MessageDetailContainer', () => {
|
||||
const server = mswServer(handlers)
|
||||
beforeAll(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.dontMock()
|
||||
server.listen()
|
||||
|
||||
window.matchMedia = jest.fn().mockImplementation(() => {
|
||||
|
@ -67,8 +62,6 @@ describe('MessageDetailContainer', () => {
|
|||
|
||||
afterAll(() => {
|
||||
server.close()
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.enableMocks()
|
||||
})
|
||||
|
||||
const setup = ({
|
||||
|
|
|
@ -26,9 +26,6 @@ import React from 'react'
|
|||
import {render, fireEvent} from '@testing-library/react'
|
||||
import {responsiveQuerySizes} from '../../../util/utils'
|
||||
import waitForApolloLoading from '../../../util/waitForApolloLoading'
|
||||
import {enableFetchMocks} from 'jest-fetch-mock'
|
||||
|
||||
enableFetchMocks()
|
||||
|
||||
jest.mock('../../../util/utils', () => ({
|
||||
...jest.requireActual('../../../util/utils'),
|
||||
|
@ -39,8 +36,6 @@ describe('CanvasInbox App Container', () => {
|
|||
const server = mswServer(handlers)
|
||||
|
||||
beforeAll(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.dontMock()
|
||||
server.listen()
|
||||
window.matchMedia = jest.fn().mockImplementation(() => {
|
||||
return {
|
||||
|
@ -64,8 +59,6 @@ describe('CanvasInbox App Container', () => {
|
|||
|
||||
afterAll(() => {
|
||||
server.close()
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.enableMocks()
|
||||
window.ENV = {}
|
||||
})
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@ import {mswServer} from '../../../../../shared/msw/mswServer'
|
|||
import React from 'react'
|
||||
import {responsiveQuerySizes} from '../../../util/utils'
|
||||
import {ConversationContext} from '../../../util/constants'
|
||||
import {enableFetchMocks} from 'jest-fetch-mock'
|
||||
|
||||
enableFetchMocks()
|
||||
|
||||
jest.mock('../../../util/utils', () => ({
|
||||
...jest.requireActual('../../../util/utils'),
|
||||
|
@ -40,8 +37,6 @@ jest.mock('../../../util/utils', () => ({
|
|||
describe('ComposeModalContainer', () => {
|
||||
const server = mswServer(handlers)
|
||||
beforeAll(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.dontMock()
|
||||
server.listen()
|
||||
|
||||
// Add appropriate mocks for responsive
|
||||
|
@ -67,8 +62,6 @@ describe('ComposeModalContainer', () => {
|
|||
|
||||
afterAll(() => {
|
||||
server.close()
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.enableMocks()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -25,9 +25,6 @@ import React from 'react'
|
|||
import {render, fireEvent, waitFor, screen} from '@testing-library/react'
|
||||
import waitForApolloLoading from '../../../util/waitForApolloLoading'
|
||||
import {responsiveQuerySizes} from '../../../util/utils'
|
||||
import {enableFetchMocks} from 'jest-fetch-mock'
|
||||
|
||||
enableFetchMocks()
|
||||
|
||||
jest.mock('../../../util/utils', () => ({
|
||||
...jest.requireActual('../../../util/utils'),
|
||||
|
@ -57,8 +54,6 @@ describe('ConversationListContainer', () => {
|
|||
}
|
||||
|
||||
beforeAll(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.dontMock()
|
||||
server.listen()
|
||||
|
||||
// Add appropriate mocks for responsive
|
||||
|
@ -84,8 +79,6 @@ describe('ConversationListContainer', () => {
|
|||
|
||||
afterAll(() => {
|
||||
server.close()
|
||||
// eslint-disable-next-line no-undef
|
||||
fetchMock.enableMocks()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -28,9 +28,6 @@ import {
|
|||
MOCK_ENROLLMENTS,
|
||||
MOCK_ENROLLMENTS_WITH_OBSERVED_USERS,
|
||||
} from './mocks'
|
||||
import {enableFetchMocks} from 'jest-fetch-mock'
|
||||
|
||||
enableFetchMocks()
|
||||
|
||||
const GRADING_PERIODS_URL = encodeURI(
|
||||
'/api/v1/courses/12?include[]=grading_periods&include[]=current_grading_period_scores&include[]=total_scores'
|
||||
|
|
|
@ -21,9 +21,6 @@ import {render as testingLibraryRender, act, waitFor} from '@testing-library/rea
|
|||
import ReleaseNotesList from '../ReleaseNotesList'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import {QueryProvider, queryClient} from '@canvas/query'
|
||||
import {enableFetchMocks} from 'jest-fetch-mock'
|
||||
|
||||
enableFetchMocks()
|
||||
|
||||
const render = (children: unknown) =>
|
||||
testingLibraryRender(<QueryProvider>{children}</QueryProvider>)
|
||||
|
|
|
@ -22,9 +22,7 @@ import {render} from '@testing-library/react'
|
|||
import {mount} from 'enzyme'
|
||||
import PublishButton from '../PublishButton'
|
||||
import * as apiClient from '@canvas/courses/courseAPIClient'
|
||||
import {enableFetchMocks} from 'jest-fetch-mock'
|
||||
|
||||
enableFetchMocks()
|
||||
import fetchMock from 'fetch-mock'
|
||||
|
||||
jest.mock('@canvas/courses/courseAPIClient')
|
||||
|
||||
|
@ -42,7 +40,11 @@ function createMockProps(opts = {}) {
|
|||
}
|
||||
|
||||
beforeEach(() => {
|
||||
fetch.mockResponse(JSON.stringify({}), {status: 200})
|
||||
fetchMock.mock('*', JSON.stringify({}), {status: 200})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
fetchMock.restore()
|
||||
})
|
||||
|
||||
describe('DashboardCardHeaderHero', () => {
|
||||
|
|
Loading…
Reference in New Issue