mirror of
https://github.com/kremalicious/portfolio.git
synced 2025-02-14 21:10:41 +01:00
more tests
This commit is contained in:
parent
748a467928
commit
0bc65e3184
361
jest/__fixtures__/projectImageFiles.json
Normal file
361
jest/__fixtures__/projectImageFiles.json
Normal file
@ -0,0 +1,361 @@
|
|||||||
|
{
|
||||||
|
"projectImageFiles": {
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "meta"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "projects"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "chartmogul-05"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ezeep-05"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ezeep-06"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ipixelpad-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "allinnia-02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ezeep-03"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ipdb-04"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "allinnia-03"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ezeep-07"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "unihalle-03"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "oceanprotocol-05"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "apertureloupe-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "coffeecup-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ipdb-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ezeep-04"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "mrreader-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "mrreader-02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "unihalle-02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "chartmogul-02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ipdb-03"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "bigchaindb-02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "chartmogul-03"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ipdb-02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "oceanprotocol-02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "bigchaindb-03"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ezeep-08"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ezeep-02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "oceanprotocol-03"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "outofwhaleoil-02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "bigchaindb-05"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "oceanprotocol-04"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "outofwhaleoil-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "9984-02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "niepces-camera-obscura-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "niepces-camera-obscura-02"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "adiumeetie-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "oceanprotocol-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "outofwhaleoil-03"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "unihalle-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "ezeep-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "chartmogul-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "bigchaindb-04"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "9984-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "chartmogul-04"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "mrreader-03"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "bigchaindb-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "projectpurple-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "biv-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "sharethemeal-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "allinnia-01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "package"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "day"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "download"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "blog"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "dribbble"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "email"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "favicon"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "index"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "info"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "logo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "images"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "night"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "link"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "twitter-card"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "twitter"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "styleguide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "github-header"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": {
|
||||||
|
"name": "avatar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { render } from 'react-testing-library'
|
import { render, fireEvent, waitForElement } from 'react-testing-library'
|
||||||
import { StaticQuery } from 'gatsby'
|
import { StaticQuery } from 'gatsby'
|
||||||
import Vcard, { constructVcard, toDataURL, init } from './Vcard'
|
import Vcard, { constructVcard, toDataURL, init } from './Vcard'
|
||||||
import data from '../../../jest/__fixtures__/meta.json'
|
import data from '../../../jest/__fixtures__/meta.json'
|
||||||
@ -16,6 +16,13 @@ describe('Vcard', () => {
|
|||||||
expect(container.firstChild).toBeInTheDocument()
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Button click starts download', async () => {
|
||||||
|
const { container } = render(<Vcard />)
|
||||||
|
fireEvent.click(container.firstChild)
|
||||||
|
await waitForElement(() => global.URL.createObjectURL)
|
||||||
|
expect(global.URL.createObjectURL).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
|
|
||||||
it('combined vCard download process finishes', async () => {
|
it('combined vCard download process finishes', async () => {
|
||||||
await init(data.contentYaml)
|
await init(data.contentYaml)
|
||||||
expect(global.URL.createObjectURL).toHaveBeenCalledTimes(1)
|
expect(global.URL.createObjectURL).toHaveBeenCalledTimes(1)
|
||||||
|
14
src/components/molecules/ProjectTechstack.test.jsx
Normal file
14
src/components/molecules/ProjectTechstack.test.jsx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { render } from 'react-testing-library'
|
||||||
|
import ProjectTechstack from './ProjectTechstack'
|
||||||
|
|
||||||
|
describe('ProjectTechstack', () => {
|
||||||
|
const techstack = ['CSS']
|
||||||
|
|
||||||
|
it('renders correctly', () => {
|
||||||
|
const { container } = render(<ProjectTechstack techstack={techstack} />)
|
||||||
|
|
||||||
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
|
expect(container.querySelector('li').textContent).toBe('CSS')
|
||||||
|
})
|
||||||
|
})
|
@ -19,4 +19,13 @@ describe('Header', () => {
|
|||||||
)
|
)
|
||||||
expect(container.firstChild).toBeInTheDocument()
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Availability can be hidden', () => {
|
||||||
|
const { container } = render(
|
||||||
|
<Provider value={{ dark: false, toggleDark: () => null }}>
|
||||||
|
<Header minimal={true} />
|
||||||
|
</Provider>
|
||||||
|
)
|
||||||
|
expect(container.querySelector('.availability')).not.toBeInTheDocument()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
23
src/pages/__tests__/index.test.jsx
Normal file
23
src/pages/__tests__/index.test.jsx
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { render } from 'react-testing-library'
|
||||||
|
import { StaticQuery } from 'gatsby'
|
||||||
|
import Home from '../index'
|
||||||
|
import meta from '../../../jest/__fixtures__/meta.json'
|
||||||
|
import projects from '../../../jest/__fixtures__/projects.json'
|
||||||
|
import projectImageFiles from '../../../jest/__fixtures__/projectImageFiles.json'
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
StaticQuery.mockImplementation(({ render }) => render({ ...meta }))
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Home', () => {
|
||||||
|
const data = {
|
||||||
|
...projects,
|
||||||
|
...projectImageFiles
|
||||||
|
}
|
||||||
|
|
||||||
|
it('renders correctly from data file values', () => {
|
||||||
|
const { container } = render(<Home data={data} />)
|
||||||
|
expect(container.firstChild).toBeInTheDocument()
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user