Skip to content

Commit

Permalink
Upgrade jest and fix open handles.
Browse files Browse the repository at this point in the history
closes #2950
  • Loading branch information
justinlittman committed Sep 7, 2021
1 parent bad3f72 commit 6f0a7ae
Show file tree
Hide file tree
Showing 3 changed files with 30,397 additions and 23,366 deletions.
10 changes: 7 additions & 3 deletions __tests__/components/App.test.js
Expand Up @@ -4,13 +4,18 @@ import { createStore, renderApp, createHistory } from 'testUtils'
import { createState } from 'stateUtils'
import Config from 'Config'
import Auth from '@aws-amplify/auth'
import fetchMock from 'fetch-mock-jest'

jest.mock('@aws-amplify/auth')

jest.spyOn(Config, 'useResourceTemplateFixtures', 'get').mockReturnValue(true)

const originalFetch = global.fetch
afterEach(() => global.fetch = originalFetch)
beforeEach(() => {
fetchMock.mockReset()
fetchMock.mock('https://sinopia-exports-development.s3-us-west-2.amazonaws.com', '<?xml version="1.0" encoding="UTF-8"?><ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Contents><Key>alberta_2020-09-06T00:01:18.798Z.zip</Key></Contents><Contents><Key>sinopia_export_all_2020-09-06T00:01:17.621Z.zip</Key></Contents></ListBucketResult>')
fetchMock.mock('https://id.loc.gov/vocabulary/iso639-2.json', '[{"@id": "http://id.loc.gov/vocabulary/iso639-2/tai","http://www.loc.gov/mads/rdf/v1#authoritativeLabel": [{"@language": "en","@value": "Tai languages"}]}]')
fetchMock.mock('https://ld4p.github.io/sinopia/help_and_resources/menu_content.html', '<ul><li><a href="https://github.com/ld4p/sinopia/wiki" target="_blank" rel="noopener noreferrer" className="menu-item">Sinopia help site</a></li></ul>')
})

// Mock out document.elementFromPoint used by useNavigableComponent.
global.document.elementFromPoint = jest.fn()
Expand Down Expand Up @@ -39,7 +44,6 @@ describe('<App />', () => {
})

it('loads exports', async () => {
global.fetch = jest.fn().mockResolvedValue({ text: jest.fn().mockResolvedValue('<?xml version="1.0" encoding="UTF-8"?><ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Contents><Key>alberta_2020-09-06T00:01:18.798Z.zip</Key></Contents><Contents><Key>sinopia_export_all_2020-09-06T00:01:17.621Z.zip</Key></Contents></ListBucketResult>') })
const state = createState({ noExports: true })
const store = createStore(state)
renderApp(store)
Expand Down

0 comments on commit 6f0a7ae

Please sign in to comment.