UNPKG

1.32 kBJavaScriptView Raw
1const {setter, splice, isExpression, isSetterExpression, isSpliceExpression, root} = require('../../index');
2const _ = require('lodash');
3
4describe('carmi-is', () => {
5 describe('SetterExpression', () => {
6 it('should return true if it is a setterExpression', () => {
7 const set = setter('path');
8 expect(isSetterExpression(set)).toBe(true);
9 });
10
11 it('should return false if it is not a setterExpression', () => {
12 const transformFunc = root.get('something');
13 expect(isSetterExpression(transformFunc)).toBe(false);
14 });
15 });
16
17 describe('SpliceExpression', () => {
18 it('should return true if it is a spliceExpression', () => {
19 const splicer = splice('path');
20 expect(isSpliceExpression(splicer)).toBe(true);
21 });
22
23 it('should return false if it is not a spliceExpression', () => {
24 const transformFunc = root.get('something');
25 expect(isSpliceExpression(transformFunc)).toBe(false);
26 });
27 });
28
29 describe('Expression', () => {
30 it('should return true if it is an expression', () => {
31 const expression = root.get('path');
32 expect(isExpression(expression)).toBe(true);
33 });
34
35 it('should return false if it is not an expression', () => {
36 const set = setter('path');
37 expect(isExpression(set)).toBe(false);
38 });
39 });
40});
41