1
-
import { describe, expect, test } from 'vitest'
1
+
import { bench, describe, expect, test } from 'vitest'
2
2
import { compile } from './compile'
3
3
import { buildFunction } from './functions'
4
4
import type { JSONQuery, JSONQueryCompileOptions } from './types'
@@ -53,7 +53,7 @@ describe('compile', () => {
53
53
})
54
54
55
55
test('should return undefined in case of a non existing path', () => {
56
-
expect(go({}, ['get', 'foo', 'bar'])).toEqual(undefined)
56
+
expect(go({}, ['get', 'foo', 'bar'])).toEqual(null)
57
57
})
58
58
59
59
test('should get a path using function get', () => {
@@ -179,15 +179,15 @@ describe('compile', () => {
179
179
actualErr = err
180
180
}
181
181
182
-
expect(actualErr?.message).toBe("Cannot read properties of undefined (reading 'reduce')")
182
+
expect(actualErr?.message).toBe("Cannot read properties of null (reading 'reduce')")
183
183
expect(actualErr?.jsonquery).toEqual([
184
184
{ data: scoreData, query },
185
185
{
186
186
data: scoreData.participants,
187
187
query: ['map', ['pipe', ['get', 'scores'], ['sum']]]
188
188
},
189
189
{ data: { name: 'Emily', age: 19 }, query: ['pipe', ['get', 'scores'], ['sum']] },
190
-
{ data: undefined, query: ['sum'] }
190
+
{ data: null, query: ['sum'] }
191
191
])
192
192
})
193
193
})
@@ -704,7 +704,7 @@ describe('compile', () => {
704
704
expect(go({ a: '' }, ['exists', ['get', 'a']])).toEqual(true)
705
705
expect(go({ nested: { a: 2 } }, ['exists', ['get', 'nested', 'a']])).toEqual(true)
706
706
707
-
expect(go({ a: undefined }, ['exists', ['get', 'a']])).toEqual(false)
707
+
expect(go({ a: undefined }, ['exists', ['get', 'a']])).toEqual(true)
708
708
expect(go({}, ['exists', ['get', 'a']])).toEqual(false)
709
709
expect(go({}, ['exists', ['get', 'nested', 'a']])).toEqual(false)
710
710
expect(go({}, ['exists', ['get', 'sort']])).toEqual(false)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4