Add date test that didn't work unfortunately for now and be skipped

This commit is contained in:
Wolfgang Huß 2022-08-08 14:43:03 +02:00
parent 1d63d5bf70
commit 6d38b9a232

View File

@ -61,6 +61,117 @@ describe('ContributionForm', () => {
})
})
describe('dates', () => {
beforeEach(async () => {
await wrapper.setData({
form: {
id: null,
date: '',
memo: '',
amount: '',
},
})
})
describe('actual date', () => {
describe('same month', () => {
beforeEach(async () => {
const now = new Date().toISOString()
await wrapper.findComponent({ name: 'BFormDatepicker' }).vm.$emit('input', now)
})
describe('isThisMonth', () => {
it('has true', () => {
expect(wrapper.vm.isThisMonth).toBe(true)
})
})
})
describe('month before', () => {
beforeEach(async () => {
await wrapper
.findComponent({ name: 'BFormDatepicker' })
.vm.$emit('input', wrapper.vm.minimalDate)
})
describe('isThisMonth', () => {
it('has false', () => {
expect(wrapper.vm.isThisMonth).toBe(false)
})
})
})
})
// jest-environment-jsdom-sixteen
// testEnvironment: 'jest-environment-jsdom-sixteen',
// https://www.npmjs.com/package/jest-environment-jsdom-sixteen
// https://dev.to/philw_/problems-with-using-usefaketimersmodern-in-a-create-react-app-cra-project-with-jest-26-and-lodashs-debounce-function-3ohd
describe.skip('date in middle of year', () => {
describe('same month', () => {
beforeEach(async () => {
jest.useFakeTimers('modern')
jest.setSystemTime(new Date('2020-07-06'))
const now = new Date().toISOString()
// Wolle: console.log('middle of year date now:', now)
await wrapper.findComponent({ name: 'BFormDatepicker' }).vm.$emit('input', now)
})
describe('isThisMonth', () => {
it('has true', () => {
expect(wrapper.vm.isThisMonth).toBe(true)
})
})
})
describe('month before', () => {
beforeEach(async () => {
// Wolle: console.log('middle of year date now:', wrapper.vm.minimalDate)
await wrapper
.findComponent({ name: 'BFormDatepicker' })
.vm.$emit('input', wrapper.vm.minimalDate)
})
describe('isThisMonth', () => {
it('has false', () => {
expect(wrapper.vm.isThisMonth).toBe(false)
})
})
})
})
describe.skip('date in january', () => {
describe('same month', () => {
beforeEach(async () => {
jest.useFakeTimers('modern').setSystemTime(new Date('2020-01-12'))
const now = new Date().toISOString()
// Wolle: console.log('in january date now:', now)
await wrapper.findComponent({ name: 'BFormDatepicker' }).vm.$emit('input', now)
})
describe('isThisMonth', () => {
it('has true', () => {
expect(wrapper.vm.isThisMonth).toBe(true)
})
})
})
describe('month before', () => {
beforeEach(async () => {
// Wolle: console.log('in january date wrapper.vm.minimalDate:', wrapper.vm.minimalDate)
await wrapper
.findComponent({ name: 'BFormDatepicker' })
.vm.$emit('input', wrapper.vm.minimalDate)
})
describe('isThisMonth', () => {
it('has false', () => {
expect(wrapper.vm.isThisMonth).toBe(false)
})
})
})
})
})
describe('set contrubtion', () => {
describe('fill in form data with "id === null"', () => {
const now = new Date().toISOString()