mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
* package updates * bump Next.js * update for Next.js v13 new `Link` behavior * see https://nextjs.org/docs/upgrading#link-component * test tweaks, simplify getNetworkDisplayName() * modify codeclimate excludes * test tweaks and cleanup * more cleanup * switch to Node.js v18 * back to Node.js v16 * temporarily run CI against Node.js v16 & v18 * update codeowners * fixtures fixes for asset price * switch to Node.js v18 * package updates * remark updates, typescript and test fixes * fix * test run fixes * yet another lockfileVersion update * package updates * test run fixes
71 lines
1.7 KiB
TypeScript
71 lines
1.7 KiB
TypeScript
import {
|
|
SortDirectionOptions,
|
|
SortTermOptions
|
|
} from '../../@types/aquarius/SearchQuery'
|
|
import { escapeEsReservedCharacters, getFilterTerm, generateBaseQuery } from '.'
|
|
|
|
const defaultBaseQueryReturn = {
|
|
from: 0,
|
|
query: {
|
|
bool: {
|
|
filter: [
|
|
{ terms: { chainId: [1, 3] } },
|
|
{ term: { _index: 'aquarius' } },
|
|
{ term: { 'purgatory.state': false } },
|
|
{ bool: { must_not: [{ term: { 'nft.state': 5 } }] } }
|
|
]
|
|
}
|
|
},
|
|
size: 1000
|
|
}
|
|
|
|
describe('@utils/aquarius', () => {
|
|
test('escapeEsReservedCharacters', () => {
|
|
expect(escapeEsReservedCharacters('<')).toBe('\\<')
|
|
})
|
|
|
|
test('getFilterTerm with string value', () => {
|
|
expect(getFilterTerm('hello', 'world')).toStrictEqual({
|
|
term: { hello: 'world' }
|
|
})
|
|
})
|
|
|
|
test('getFilterTerm with array value', () => {
|
|
expect(getFilterTerm('hello', ['world', 'domination'])).toStrictEqual({
|
|
terms: { hello: ['world', 'domination'] }
|
|
})
|
|
})
|
|
|
|
test('generateBaseQuery', () => {
|
|
expect(generateBaseQuery({ chainIds: [1, 3] })).toStrictEqual(
|
|
defaultBaseQueryReturn
|
|
)
|
|
})
|
|
|
|
test('generateBaseQuery aggs are passed through', () => {
|
|
expect(
|
|
generateBaseQuery({ chainIds: [1, 3], aggs: 'hello world' })
|
|
).toStrictEqual({
|
|
...defaultBaseQueryReturn,
|
|
aggs: 'hello world'
|
|
})
|
|
})
|
|
|
|
test('generateBaseQuery sortOptions are passed through', () => {
|
|
expect(
|
|
generateBaseQuery({
|
|
chainIds: [1, 3],
|
|
sortOptions: {
|
|
sortBy: SortTermOptions.Created,
|
|
sortDirection: SortDirectionOptions.Ascending
|
|
}
|
|
})
|
|
).toStrictEqual({
|
|
...defaultBaseQueryReturn,
|
|
sort: {
|
|
'nft.created': 'asc'
|
|
}
|
|
})
|
|
})
|
|
})
|