1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-09 04:05:01 +00:00
mon-entreprise/test/date.test.js
Johan Girod 665943288a ⚙️ Ajoute le mécanisme régularisation
- améliore la gestion des unités pour les variables temporelles
2020-03-18 15:46:38 +01:00

19 lines
643 B
JavaScript

import { expect } from 'chai'
import { getDifferenceInMonths } from '../source/engine/date'
describe('Date : getDifferenceInMonths', () => {
it('should compute the difference for one full month', () => {
expect(getDifferenceInMonths('01/01/2020', '31/01/2020')).to.equal(1)
})
it('should compute the difference for one month and one day', () => {
expect(getDifferenceInMonths('01/01/2020', '01/02/2020')).to.equal(
1 + 1 / 29
)
})
it('should compute the difference for 2 days between months', () => {
expect(getDifferenceInMonths('31/01/2020', '01/02/2020')).to.approximately(
1 / 31 + 1 / 29,
0.000000000001
)
})
})