1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-23 01:29:41 +01:00
portfolio/tests/setup-test-env.js

49 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-07-08 18:29:29 +02:00
import '@testing-library/jest-dom/extend-expect'
2019-04-16 21:21:01 +02:00
import 'jest-canvas-mock'
2019-11-13 14:08:57 +01:00
import { StaticQuery, useStaticQuery } from 'gatsby'
2021-03-13 01:03:23 +01:00
import { getSrc } from 'gatsby-plugin-image'
2019-11-13 14:08:57 +01:00
import meta from './__fixtures__/meta.json'
import resume from './__fixtures__/resume.json'
2019-11-25 13:46:44 +01:00
import projects from './__fixtures__/projects.json'
2019-11-13 14:08:57 +01:00
import axios from 'axios'
jest.mock('axios')
2019-11-13 14:08:57 +01:00
beforeAll(() => {
//
// Gatsby GraphQL data
//
2021-03-13 01:03:23 +01:00
const photoSrc = getSrc(resume.contentJson.basics.picture)
2019-11-13 14:08:57 +01:00
const dataMock = {
...meta,
...resume,
photoSrc,
2019-11-25 13:46:44 +01:00
...projects
2019-11-13 14:08:57 +01:00
}
StaticQuery.mockReturnValue({ ...dataMock })
useStaticQuery.mockReturnValue({ ...dataMock })
//
// Axios mocks
//
const responseMock = {
status: 'ok',
data: {
now: {
city: 'Lisbon',
country: 'Portugal',
country_code: 'PT',
date_start: '2021-10-01'
},
next: {
city: 'Barcelona',
country: 'Spain',
date_start: '2021-10-04'
}
}
}
axios.mockResolvedValue(responseMock)
2019-11-13 14:08:57 +01:00
})