Skip to content

Commit 377bf8b

Browse files
committed
Add tests for parseInternalValue function
1 parent 5122e22 commit 377bf8b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { parseInternalValue } from '../../select';
2+
3+
describe('parseInternalValue', () => {
4+
let value;
5+
let isMulti;
6+
7+
it('single', () => {
8+
value = 'cats';
9+
isMulti = undefined;
10+
expect(parseInternalValue(value, isMulti)).toEqual('cats');
11+
});
12+
13+
it('multi and array', () => {
14+
value = ['cats', { value: 'dogs' }];
15+
isMulti = true;
16+
expect(parseInternalValue(value, isMulti)).toEqual(['cats', 'dogs']);
17+
});
18+
19+
it('single and array', () => {
20+
value = ['cats', { value: 'dogs' }];
21+
isMulti = false;
22+
expect(parseInternalValue(value, isMulti)).toEqual('cats');
23+
});
24+
25+
it('single and array - object', () => {
26+
value = [{ value: 'dogs' }];
27+
isMulti = false;
28+
expect(parseInternalValue(value, isMulti)).toEqual('dogs');
29+
});
30+
31+
it('single and undefined', () => {
32+
value = [];
33+
isMulti = false;
34+
expect(parseInternalValue(value, isMulti)).toEqual(undefined);
35+
});
36+
});

0 commit comments

Comments
 (0)