forked from elastic/eui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemotion-prefix.test.ts
52 lines (50 loc) · 1.96 KB
/
emotion-prefix.test.ts
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
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { replaceEmotionPrefix } from './emotion-prefix';
describe('replaceEmotionPrefix', () => {
it('matches EUI component Emotion classes', () => {
expect(replaceEmotionPrefix('css-abc1234-euiComponent')).toBe(
'emotion-euiComponent'
);
});
it('matches EUI component Emotion classes with variants', () => {
expect(replaceEmotionPrefix('css-abc1234-euiComponent-primary-m')).toBe(
'emotion-euiComponent-primary-m'
);
});
it('matches EUI component Emotion classes with descendents', () => {
expect(replaceEmotionPrefix('css-abc1234-euiComponent__child')).toBe(
'emotion-euiComponent__child'
);
});
it('matches chained EUI component Emotion classes', () => {
expect(
replaceEmotionPrefix('css-abc1234-euiComponentStyles-EuiComponent')
).toBe('emotion-euiComponentStyles-EuiComponent');
});
it('matches EUI component Emotion classes with uppercase start', () => {
expect(replaceEmotionPrefix('css-abc1234-EuiComponent')).toBe(
'emotion-EuiComponent'
);
});
it('does not match EUI Sass classes', () => {
expect(replaceEmotionPrefix('euiMark')).toBe('euiMark');
expect(replaceEmotionPrefix('euiButton--primary')).toBe(
'euiButton--primary'
);
});
it('does not match non-EUI classes', () => {
expect(replaceEmotionPrefix('css-euiMark')).toBe('css-euiMark');
expect(
replaceEmotionPrefix('css-abc123-kibanaClassName-euiMockComponent')
).toBe('css-abc123-kibanaClassName-euiMockComponent');
expect(replaceEmotionPrefix('kibanaClassName-euiMockComponent')).toBe(
'kibanaClassName-euiMockComponent'
);
});
});