@@ -12,7 +12,12 @@ import { getEmployeePayCodes } from '../queries/employees/getEmployeePayCodes.js
1212import { getTimeCodes } from '../queries/employees/getTimeCodes.js'
1313import { getTimesheetBatchEntries } from '../queries/employees/getTimesheetBatchEntries.js'
1414
15- import { mssqlConfig , validActivityId , validEmployeeNumber , validJobId } from './config.js'
15+ import {
16+ mssqlConfig ,
17+ validActivityId ,
18+ validEmployeeNumber ,
19+ validJobId
20+ } from './config.js'
1621
1722Debug . enable ( DEBUG_ENABLE_NAMESPACES )
1823
@@ -72,10 +77,7 @@ await describe('queries/employees', async () => {
7277 validEmployeeNumber
7378 )
7479
75- assert . strictEqual (
76- timesheetBatchEntry . timesheetHours ,
77- timesheetHours
78- )
80+ assert . strictEqual ( timesheetBatchEntry . timesheetHours , timesheetHours )
7981 }
8082 } )
8183
@@ -104,27 +106,48 @@ await describe('queries/employees', async () => {
104106 }
105107 } )
106108
107- await it ( 'Retrieves timesheet batch entries by job ID' , async ( ) => {
109+ await it ( 'Retrieves timesheet batch entries by max age days' , async ( ) => {
110+ const timesheetMaxAgeDays = 90
108111
109112 const timesheetBatchEntries = await getTimesheetBatchEntries (
110113 mssqlConfig ,
111114 {
112- jobId : validJobId
115+ timesheetMaxAgeDays
113116 }
114117 )
115118
116119 assert . ok ( timesheetBatchEntries . length > 0 )
117120
121+ const currentDate = new Date ( )
122+
118123 for ( const timesheetBatchEntry of timesheetBatchEntries ) {
119- assert . strictEqual (
120- timesheetBatchEntry . jobId ,
121- validJobId
124+ const timesheetDate = timesheetBatchEntry . timesheetDate as Date
125+
126+ const ageInDays = Math . floor (
127+ ( currentDate . getTime ( ) - timesheetDate . getTime ( ) ) /
128+ ( 1000 * 60 * 60 * 24 )
122129 )
130+
131+ assert . ok ( ageInDays <= timesheetMaxAgeDays )
123132 }
124133 } )
125134
126- await it ( 'Retrieves timesheet batch entries by activity ID' , async ( ) => {
135+ await it ( 'Retrieves timesheet batch entries by job ID' , async ( ) => {
136+ const timesheetBatchEntries = await getTimesheetBatchEntries (
137+ mssqlConfig ,
138+ {
139+ jobId : validJobId
140+ }
141+ )
127142
143+ assert . ok ( timesheetBatchEntries . length > 0 )
144+
145+ for ( const timesheetBatchEntry of timesheetBatchEntries ) {
146+ assert . strictEqual ( timesheetBatchEntry . jobId , validJobId )
147+ }
148+ } )
149+
150+ await it ( 'Retrieves timesheet batch entries by activity ID' , async ( ) => {
128151 const timesheetBatchEntries = await getTimesheetBatchEntries (
129152 mssqlConfig ,
130153 {
@@ -135,10 +158,7 @@ await describe('queries/employees', async () => {
135158 assert . ok ( timesheetBatchEntries . length > 0 )
136159
137160 for ( const timesheetBatchEntry of timesheetBatchEntries ) {
138- assert . strictEqual (
139- timesheetBatchEntry . activityId ,
140- validActivityId
141- )
161+ assert . strictEqual ( timesheetBatchEntry . activityId , validActivityId )
142162 }
143163 } )
144164 } )
0 commit comments