mirror of
https://github.com/theoludwig/theoludwig.git
synced 2025-05-29 22:37:44 +02:00
chore: remove jest -> cypress for unit tests
This commit is contained in:
18
cypress/component/Footer.cy.tsx
Normal file
18
cypress/component/Footer.cy.tsx
Normal file
@ -0,0 +1,18 @@
|
||||
import { Footer } from 'components/Footer'
|
||||
|
||||
describe('<Footer />', () => {
|
||||
it('should render with appropriate link tag version', () => {
|
||||
const version = '1.0.0'
|
||||
cy.mount(<Footer version={version} />)
|
||||
cy.contains('Divlo')
|
||||
.get('[data-cy=version-link]')
|
||||
.should('have.text', version)
|
||||
.should(
|
||||
'have.attr',
|
||||
'href',
|
||||
`https://github.com/Divlo/Divlo/releases/tag/v${version}`
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
17
cypress/component/utils/getAge.cy.ts
Normal file
17
cypress/component/utils/getAge.cy.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { getAge } from '../../../utils/getAge'
|
||||
|
||||
describe('utils/getAge', () => {
|
||||
it('should calculate the right age of a person', () => {
|
||||
cy.clock(new Date('2018-03-20')).then(() => {
|
||||
const birthDate = new Date('1980-02-20')
|
||||
expect(getAge(birthDate)).equal(38)
|
||||
})
|
||||
})
|
||||
|
||||
it('should calculate the right age of a person (taking into account the months)', () => {
|
||||
cy.clock(new Date('2018-03-20')).then(() => {
|
||||
const birthDate = new Date('1980-07-20')
|
||||
expect(getAge(birthDate)).equal(37)
|
||||
})
|
||||
})
|
||||
})
|
@ -56,3 +56,5 @@ describe('Common > Header', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
||||
|
@ -5,3 +5,5 @@ describe('Page /404', () => {
|
||||
cy.get('[data-cy=status-code]').contains('404')
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
||||
|
@ -5,3 +5,5 @@ describe('Page /500', () => {
|
||||
cy.get('[data-cy=status-code]').contains('500')
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
||||
|
@ -11,3 +11,5 @@ describe('Page /blog/[slug]', () => {
|
||||
cy.get('[data-cy=status-code]').contains('404')
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
||||
|
@ -20,3 +20,5 @@ describe('Page /blog', () => {
|
||||
.should('eq', '/blog/hello-world')
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
||||
|
@ -17,3 +17,5 @@ describe('Page /', () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
||||
|
1
cypress/fixtures/example.json
Normal file
1
cypress/fixtures/example.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
3
cypress/support/commands.ts
Normal file
3
cypress/support/commands.ts
Normal file
@ -0,0 +1,3 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
export {}
|
14
cypress/support/component-index.html
Normal file
14
cypress/support/component-index.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<title>Components App</title>
|
||||
<!-- Used by Next.js to inject CSS. -->
|
||||
<div id="__next_css__DO_NOT_USE__"></div>
|
||||
</head>
|
||||
<body>
|
||||
<div data-cy-root></div>
|
||||
</body>
|
||||
</html>
|
13
cypress/support/component.ts
Normal file
13
cypress/support/component.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { mount } from 'cypress/react'
|
||||
|
||||
import './commands'
|
||||
|
||||
declare global {
|
||||
namespace Cypress {
|
||||
interface Chainable {
|
||||
mount: typeof mount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cypress.Commands.add('mount', mount)
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"types": ["cypress"],
|
||||
"isolatedModules": false
|
||||
},
|
||||
"include": ["../node_modules/cypress", "./**/*.ts"]
|
||||
}
|
Reference in New Issue
Block a user