-
-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathprop-utils.test.js
More file actions
52 lines (44 loc) · 1.22 KB
/
prop-utils.test.js
File metadata and controls
52 lines (44 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* eslint-env jest */
import { getPropsStartingWith, getDataAttributes, getAriaAttributes } from '../prop-utils';
describe('getPropsStartingWith', () => {
test('should return the props that start with the given string', () => {
const props = {
'test-1': 'test',
'test-2': 'test 2',
'another-prop': 'test 3',
};
const result = getPropsStartingWith('test-', props);
expect(result).toEqual({
'test-1': 'test',
'test-2': 'test 2',
});
});
});
describe('getDataAttributes', () => {
test('should return only the props that start with `data-`', () => {
const props = {
'data-ci': 'ci',
'data-gtm': 'gtm',
children: 'test children',
};
const result = getDataAttributes(props);
expect(result).toEqual({
'data-ci': 'ci',
'data-gtm': 'gtm',
});
});
});
describe('getAriaAttributes', () => {
test('should return only the props that start with `aria-`', () => {
const props = {
'aria-label': 'a11y rocks!',
'aria-checked': 'true',
children: 'test children',
};
const result = getAriaAttributes(props);
expect(result).toEqual({
'aria-label': 'a11y rocks!',
'aria-checked': 'true',
});
});
});