Skip to content

Instantly share code, notes, and snippets.

@evert0n
Last active January 25, 2023 02:24
Show Gist options
  • Save evert0n/42851aa29efeed90453b732bdd4782df to your computer and use it in GitHub Desktop.
Save evert0n/42851aa29efeed90453b732bdd4782df to your computer and use it in GitHub Desktop.
Eligible Annual Leave Challenge

Annual Paid Leave Allowance

  1. Paid leave shall be granted after 3 months have elapsed from the date of hire.

  2. Employees and full-time workers shall be granted paid leave as outlined in the table below, beginning after 3 months have elapsed since their hire date.

Month of Hire Month when leave is granted Number of days granted
January April 10
February May 10
March June 10
April July 10
May August 10
June September 10
July October 4
August November 3
September December 2
October - -
November - -
December - -
  1. From the following year onward, those who have worked at least 80% of the working days will be granted the number of days of annual paid leave on January 1 in accordance with their years of service, as shown in the table below. In the event of a change of employment status from part-time worker to employee, the number of years of service will be accredited to the employee.
Years of continuous service (as of January 1) Number of days granted
Less than 1 year 11
More than 1 year, but less than 2 years 12
More than 2 years, but less than 3 years 14
More than 3 years, but less than 4 years 16
More than 4 years, but less than 5 years 18
More than 5 years 20

Challenge

Given the Annual Paid Leave rules above please:

  1. Create a repository setup with Typescript and Jest for testing
  2. Copy the leave.ts and leave.test.ts files attached to this gist to it
  3. Write a function, let's call it getEligibleAnnualLeaves which takes the params startDate and attendancePercentage
  4. startDate param type is Date, this is the date the employee started working in the organization
  5. attendancePercentage param type is Number, this is percentage of attendance in the last year, for this challenge let's set this value to always 80, it's calculation is out of the scope of this challenge so always use 80
  6. today param type is Date, this is an utility params to easy the testing, but if you want go further and improve it with a different approach it's even better
  7. The function should return Promise<Number>
  8. Attached to gist a test file for JEST all tests should pass with this function
  9. Provide the jest results running the test suite attached to this gist

Additional remarks

  1. You can add more params to the function if needed
  2. In our implementation we are using date-fns you are free to use any other library
import {
parseISO,
formatISO,
format,
startOfTomorrow,
startOfYesterday,
addYears,
subYears,
differenceInCalendarYears,
} from 'date-fns'
import { getEligibleAnnualLeaves } from './leave'
describe('Eligible Annual Leaves', () => {
// January
test('Started working in January, current month is January and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-01-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in January, current month is February and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-01-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in January, current month is March and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-03-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in January, current month is April and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-04-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in January, current month is May and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-05-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in January, current month is June and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-06-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in January, current month is July and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-07-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in January, current month is August and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-08-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in January, current month is September and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-09-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in January, current month is October and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-10-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in January, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in January, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-01-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
// February
test('Started working in February, current month is February and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(new Date(), 'yyyy-02-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in February, current month is March and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(new Date(), 'yyyy-03-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in February, current month is April and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(new Date(), 'yyyy-04-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in February, current month is May and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(new Date(), 'yyyy-05-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in February, current month is June and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(new Date(), 'yyyy-06-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in February, current month is July and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(new Date(), 'yyyy-07-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in February, current month is August and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(new Date(), 'yyyy-08-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in February, current month is September and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(new Date(), 'yyyy-09-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in February, current month is October and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(new Date(), 'yyyy-10-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in February, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in February, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in February, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-02-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// March
test('Started working in March, current month is March and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(new Date(), 'yyyy-03-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in March, current month is April and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(new Date(), 'yyyy-04-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in March, current month is May and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(new Date(), 'yyyy-05-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in March, current month is June and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(new Date(), 'yyyy-06-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in March, current month is July and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(new Date(), 'yyyy-07-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in March, current month is August and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(new Date(), 'yyyy-08-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in March, current month is September and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(new Date(), 'yyyy-09-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in March, current month is October and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(new Date(), 'yyyy-10-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in March, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in March, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in March, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in March, current month is February next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-03-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-02-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// April
test('Started working in April, current month is April and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(new Date(), 'yyyy-04-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in April, current month is May and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(new Date(), 'yyyy-05-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in April, current month is June and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(new Date(), 'yyyy-06-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in April, current month is July and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(new Date(), 'yyyy-07-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in April, current month is August and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(new Date(), 'yyyy-08-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in April, current month is September and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(new Date(), 'yyyy-09-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in April, current month is October and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(new Date(), 'yyyy-10-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in April, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in April, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in April, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in April, current month is February next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-02-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in April, current month is March next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-04-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-03-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// May
test('Started working in May, current month is May and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-05-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in May, current month is June and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-06-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in May, current month is July and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-07-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in May, current month is August and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-08-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in May, current month is September and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-09-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in May, current month is October and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-10-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in May, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in May, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in May, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in May, current month is February next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-02-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in May, current month is March next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-03-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in May, current month is April next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-04-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// May
test('Started working in May, current month is May and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-05-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in May, current month is June and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-06-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in May, current month is July and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-07-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in May, current month is August and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-08-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in May, current month is September and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-09-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in May, current month is October and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-10-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in May, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in May, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in May, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in May, current month is February next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-02-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in May, current month is March next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-03-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in May, current month is April next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-05-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-04-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// June
test('Started working in June, current month is June and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-06-01'))
let today = parseISO(format(new Date(), 'yyyy-06-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in June, current month is July and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-06-01'))
let today = parseISO(format(new Date(), 'yyyy-07-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in June, current month is August and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-06-01'))
let today = parseISO(format(new Date(), 'yyyy-08-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in June, current month is September and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-06-01'))
let today = parseISO(format(new Date(), 'yyyy-09-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in June, current month is October and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-06-01'))
let today = parseISO(format(new Date(), 'yyyy-10-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in June, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-06-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in June, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-06-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
10
)
})
test('Started working in June, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-06-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in June, current month is February next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-06-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-02-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in June, current month is March next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-06-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-03-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in June, current month is April next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-06-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-04-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// July
test('Started working in July, current month is July and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(new Date(), 'yyyy-07-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in July, current month is August and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(new Date(), 'yyyy-08-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in July, current month is September and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(new Date(), 'yyyy-09-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in July, current month is October and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(new Date(), 'yyyy-10-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
4
)
})
test('Started working in July, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
4
)
})
test('Started working in July, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
4
)
})
test('Started working in July, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in July, current month is February next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-02-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in July, current month is March next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-03-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in July, current month is April next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-04-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in July, current month is May next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-05-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in July, current month is June next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-07-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-06-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// August
test('Started working in August, current month is August and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(new Date(), 'yyyy-08-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in August, current month is September and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(new Date(), 'yyyy-09-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in August, current month is October and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(new Date(), 'yyyy-10-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in August, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
3
)
})
test('Started working in August, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
3
)
})
test('Started working in August, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in August, current month is February next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-02-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in August, current month is March next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-03-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in August, current month is April next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-04-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in August, current month is May next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-05-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in August, current month is June next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-06-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in August, current month is July next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-08-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-07-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// September
test('Started working in September, current month is September and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(new Date(), 'yyyy-09-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in September, current month is October and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(new Date(), 'yyyy-10-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in September, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in September, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
2
)
})
test('Started working in September, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in September, current month is February next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-02-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in September, current month is March next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-03-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in September, current month is April next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-04-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in September, current month is May next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-05-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in September, current month is June next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-06-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in September, current month is July next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-07-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in September, current month is August next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-09-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-08-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// October
test('Started working in October, current month is October and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(new Date(), 'yyyy-10-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in October, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in October, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in October, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in October, current month is February next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-02-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in October, current month is March next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-03-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in October, current month is April next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-04-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in October, current month is May next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-05-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in October, current month is June next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-06-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in October, current month is July next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-07-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in October, current month is August next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-08-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in October, current month is September next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-10-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-09-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// November
test('Started working in November, current month is November and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(new Date(), 'yyyy-11-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in November, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in November, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in November, current month is February next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-02-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in November, current month is March next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-03-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in November, current month is April next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-04-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in November, current month is May next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-05-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in November, current month is June next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-06-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in November, current month is July next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-07-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in November, current month is August next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-08-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in November, current month is September next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-09-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in November, current month is October next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-11-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-10-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// December
test('Started working in December, current month is December and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(new Date(), 'yyyy-12-01'))
expect(await getEligibleAnnualLeaves(startingDate, 0, today)).toBe(
0
)
})
test('Started working in December, current month is January next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-01-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in December, current month is February next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-02-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in December, current month is March next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-03-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in December, current month is April next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-04-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in December, current month is May next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-05-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in December, current month is June next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-06-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in December, current month is July next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-07-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in December, current month is August next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-08-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in December, current month is September next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-09-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in December, current month is October next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-10-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working in December, current month is November next year and less than a year', async () => {
let startingDate = parseISO(format(new Date(), 'yyyy-12-01'))
let today = parseISO(format(addYears(new Date(), 1), 'yyyy-11-01'))
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
// Number of worked years
test('Started working less than 1 year ago', async () => {
let startingDate = subYears(startOfTomorrow(), 1)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(11)
})
test('Started working more than 1 year ago', async () => {
let startingDate = subYears(new Date(), 1)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(12)
})
test('Started working less than 2 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 2)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(12)
})
test('Started working more than 2 years ago', async () => {
let startingDate = subYears(new Date(), 2)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(14)
})
test('Started working less than 3 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 3)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(14)
})
test('Started working more than 3 years ago', async () => {
let startingDate = subYears(new Date(), 3)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(16)
})
test('Started working less than 4 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 4)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(16)
})
test('Started working more than 4 years ago', async () => {
let startingDate = subYears(new Date(), 4)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(18)
})
test('Started working less than 5 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 5)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(18)
})
test('Started working more than 5 years ago', async () => {
let startingDate = subYears(new Date(), 5)
let today = new Date()
let workingCalendarYears = differenceInCalendarYears(
today,
new Date(startingDate)
)
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(20)
})
test('Started working less than 10 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 10)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(20)
})
test('Started working more than 10 years ago', async () => {
let startingDate = subYears(new Date(), 10)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(20)
})
test('Started working less than 20 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 20)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(20)
})
test('Started working more than 20 years ago', async () => {
let startingDate = subYears(new Date(), 20)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(20)
})
test('Started working less than 30 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 30)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 80, today)
).toBe(20)
})
// Attendance last year less than 80%
test('Started working less than 1 year ago', async () => {
let startingDate = subYears(startOfTomorrow(), 1)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
test('Started working more than 1 year ago', async () => {
let startingDate = subYears(new Date(), 1)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
test('Started working less than 2 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 2)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
test('Started working more than 2 years ago', async () => {
let startingDate = subYears(new Date(), 2)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
test('Started working less than 3 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 3)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
test('Started working more than 3 years ago', async () => {
let startingDate = subYears(new Date(), 3)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
test('Started working less than 4 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 4)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
test('Started working more than 4 years ago', async () => {
let startingDate = subYears(new Date(), 4)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
test('Started working less than 5 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 5)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
test('Started working more than 5 years ago', async () => {
let startingDate = subYears(new Date(), 5)
let today = new Date()
let workingCalendarYears = differenceInCalendarYears(
today,
new Date(startingDate)
)
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
test('Started working less than 10 years ago', async () => {
let startingDate = subYears(startOfTomorrow(), 10)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
test('Started working more than 10 years ago', async () => {
let startingDate = subYears(new Date(), 10)
let today = new Date()
expect(
await getEligibleAnnualLeaves(startingDate, 75, today)
).toBe(10)
})
})
export async function getEligibleAnnualLeaves(
startDate: Date,
attendancePercent: Number = 80,
today: Date = new Date()
): Promise<Number> {
// your code here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment