keep up with the latest specs for since/until filter

This commit is contained in:
jiftechnify 2023-07-15 11:51:28 +09:00 committed by fiatjaf_
parent fec40490a2
commit 1a23f5ee01
2 changed files with 21 additions and 1 deletions

View File

@ -115,6 +115,16 @@ describe('Filter', () => {
expect(result).toEqual(false)
})
it('should return true when the timestamp of event is equal to the filter since value', () => {
const filter = {since: 100}
const event = buildEvent({created_at: 100})
const result = matchFilter(filter, event)
expect(result).toEqual(true)
})
it('should return false when the event is after the filter until value', () => {
const filter = {until: 100}
@ -124,6 +134,16 @@ describe('Filter', () => {
expect(result).toEqual(false)
})
it('should return true when the timestamp of event is equal to the filter until value', () => {
const filter = {until: 100}
const event = buildEvent({created_at: 100})
const result = matchFilter(filter, event)
expect(result).toEqual(true)
})
})
describe('matchFilters', () => {

View File

@ -42,7 +42,7 @@ export function matchFilter(
}
if (filter.since && event.created_at < filter.since) return false
if (filter.until && event.created_at >= filter.until) return false
if (filter.until && event.created_at > filter.until) return false
return true
}