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
Matthias Kretschmann 5a310017b9
add location (#692)
* add current and next location

* add documentation

* api -> src/api symlink so local dev & Vercel work

* add to footer

* test changes

* styling changes

* spacing

* layout fixes
2021-10-19 21:47:19 +01:00

49 lines
1.0 KiB
JavaScript

import '@testing-library/jest-dom/extend-expect'
import 'jest-canvas-mock'
import { StaticQuery, useStaticQuery } from 'gatsby'
import { getSrc } from 'gatsby-plugin-image'
import meta from './__fixtures__/meta.json'
import resume from './__fixtures__/resume.json'
import projects from './__fixtures__/projects.json'
import axios from 'axios'
jest.mock('axios')
beforeAll(() => {
//
// Gatsby GraphQL data
//
const photoSrc = getSrc(resume.contentJson.basics.picture)
const dataMock = {
...meta,
...resume,
photoSrc,
...projects
}
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)
})