mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { expect } from 'chai'
|
|
import { matchOperator } from '../../../src/parser/match-operator'
|
|
import { defaultOperators } from '../../../src'
|
|
import { createTrie } from '../../../src/util/operator-trie'
|
|
|
|
describe('parser/matchOperator()', function () {
|
|
const trie = createTrie(defaultOperators)
|
|
it('should match contains', () => {
|
|
expect(matchOperator('contains', 0, trie)).to.equal(8)
|
|
})
|
|
it('should match comparision', () => {
|
|
expect(matchOperator('>', 0, trie)).to.equal(1)
|
|
expect(matchOperator('>=', 0, trie)).to.equal(2)
|
|
expect(matchOperator('<', 0, trie)).to.equal(1)
|
|
expect(matchOperator('<=', 0, trie)).to.equal(2)
|
|
})
|
|
it('should match binary logic', () => {
|
|
expect(matchOperator('and', 0, trie)).to.equal(3)
|
|
expect(matchOperator('or', 0, trie)).to.equal(2)
|
|
})
|
|
it('should not match if word not terminate', () => {
|
|
expect(matchOperator('true1', 0, trie)).to.equal(-1)
|
|
expect(matchOperator('containsa', 0, trie)).to.equal(-1)
|
|
})
|
|
it('should match if word boundary found', () => {
|
|
expect(matchOperator('>=1', 0, trie)).to.equal(2)
|
|
expect(matchOperator('contains b', 0, trie)).to.equal(8)
|
|
})
|
|
})
|