1 | 'use strict'
|
2 |
|
3 | import { Operator } from '../src/index'
|
4 |
|
5 | describe('Operator', () => {
|
6 | describe('constructor()', () => {
|
7 | function subject (...args) {
|
8 | return new Operator(...args)
|
9 | }
|
10 |
|
11 | it('adds the operator', () => {
|
12 | let operator = subject('startsWithLetter', (factValue, jsonValue) => {
|
13 | return factValue[0] === jsonValue
|
14 | })
|
15 | expect(operator.name).to.equal('startsWithLetter')
|
16 | expect(operator.cb).to.an.instanceof(Function)
|
17 | })
|
18 |
|
19 | it('operator name', () => {
|
20 | expect(() => {
|
21 | subject()
|
22 | }).to.throw(/Missing operator name/)
|
23 | })
|
24 |
|
25 | it('operator definition', () => {
|
26 | expect(() => {
|
27 | subject('startsWithLetter')
|
28 | }).to.throw(/Missing operator callback/)
|
29 | })
|
30 | })
|
31 | })
|