Skip to content

Commit

Permalink
Test(filters): cleanup filter object type for nth tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Quazia committed Feb 6, 2024
1 parent f9569fb commit 9c32eaa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/filter/filters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
handleRegex,
handleSome,
} from './filters.js'
import type { Filter, FilterObject, FilterOperator } from './types.js'
import type { Filter, FilterObject } from './types.js'
import { assertType, describe, expect, test } from 'vitest'

describe('parser', () => {
Expand Down Expand Up @@ -51,23 +51,23 @@ describe('parser', () => {

describe('nth', () => {
test('should return true if the nth item in the array meets the condition', () => {
const filter = { index: 1, value: { $gte: '50' } as FilterOperator }
const filter = { index: 1, value: { $gte: '50' } }
const context = ['10', '100', '10', '60']
const result = handleNth(context, filter)
assertType<boolean>(result)
expect(result).to.be.true
})

test('should return false if the nth item in the array does not meet the condition', () => {
const filter = { index: 2, value: { $gte: '50' } as FilterOperator }
const filter = { index: 2, value: { $gte: '50' } }
const context = ['10', '100', '10', '60']
const result = handleNth(context, filter)
assertType<boolean>(result)
expect(result).to.be.false
})

test('should return false if n overflows the array', () => {
const filter = { index: 4, value: { $gte: '50' } as FilterOperator }
const filter = { index: 4, value: { $gte: '50' } }
const context = ['10', '100', '10', '60']
const result = handleNth(context, filter)
assertType<boolean>(result)
Expand Down

0 comments on commit 9c32eaa

Please sign in to comment.