1
1
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:
Divlo
2022-07-28 22:51:12 +02:00
parent 8bc1471cbb
commit 1f4aa54211
33 changed files with 187 additions and 4372 deletions

View 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 {}

View 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)
})
})
})

View File

@ -56,3 +56,5 @@ describe('Common > Header', () => {
})
})
})
export {}

View File

@ -5,3 +5,5 @@ describe('Page /404', () => {
cy.get('[data-cy=status-code]').contains('404')
})
})
export {}

View File

@ -5,3 +5,5 @@ describe('Page /500', () => {
cy.get('[data-cy=status-code]').contains('500')
})
})
export {}

View File

@ -11,3 +11,5 @@ describe('Page /blog/[slug]', () => {
cy.get('[data-cy=status-code]').contains('404')
})
})
export {}

View File

@ -20,3 +20,5 @@ describe('Page /blog', () => {
.should('eq', '/blog/hello-world')
})
})
export {}

View File

@ -17,3 +17,5 @@ describe('Page /', () => {
}
})
})
export {}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,3 @@
/// <reference types="cypress" />
export {}

View 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>

View 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)

View File

@ -1,9 +0,0 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": true,
"types": ["cypress"],
"isolatedModules": false
},
"include": ["../node_modules/cypress", "./**/*.ts"]
}