@@ -6,20 +6,25 @@ import * as primitiveTokens from '../design-tokens/primitive.json'
6
6
import * as actionIconTokens from '../design-tokens/bg-actions.json'
7
7
import * as standardIconTokens from '../design-tokens/bg-standard.json'
8
8
import * as customIconTokens from '../design-tokens/bg-custom.json'
9
+ import * as newPaletteValues from '../design-tokens/new-palette.json'
9
10
10
11
import Assistant from '..'
11
12
13
+ const newPaletteLength = Object . keys ( newPaletteValues ) . length - 1
14
+
12
15
test ( 'border-color' , async ( ) => {
13
16
const { violations, ruleErrors } = await testAssistant (
14
17
resolve ( __dirname , './test.sketch' ) ,
15
18
Assistant ,
16
19
)
17
- const borderColorViolations = violations . find (
20
+ const borderColorViolations = violations . filter (
18
21
( v ) => v . ruleName === 'lightning-design-system-linter/border-color' ,
19
- ) ?. objects
22
+ )
20
23
21
24
expect ( borderColorViolations ?. length ) . toBe ( 1 )
22
- expect ( borderColorViolations ? borderColorViolations [ 0 ] . name : null ) . toBe ( 'Bad Rectangle' )
25
+ expect ( borderColorViolations ? borderColorViolations [ 0 ] . objects [ 0 ] . name : null ) . toBe (
26
+ 'Bad Rectangle' ,
27
+ )
23
28
expect ( ruleErrors ) . toHaveLength ( 0 )
24
29
} )
25
30
@@ -28,12 +33,13 @@ test('fill-color', async () => {
28
33
resolve ( __dirname , './test.sketch' ) ,
29
34
Assistant ,
30
35
)
31
- const fillColorViolations = violations . find (
36
+
37
+ const fillColorViolations = violations . filter (
32
38
( v ) => v . ruleName === 'lightning-design-system-linter/fill-color' ,
33
- ) ?. objects
39
+ )
34
40
35
41
expect ( fillColorViolations ?. length ) . toBe ( 1 )
36
- expect ( fillColorViolations ? fillColorViolations [ 0 ] . name : null ) . toBe ( 'Bad Rectangle' )
42
+ expect ( fillColorViolations ? fillColorViolations [ 0 ] . objects [ 0 ] . name : null ) . toBe ( 'Bad Rectangle' )
37
43
expect ( ruleErrors ) . toHaveLength ( 0 )
38
44
} )
39
45
@@ -42,12 +48,13 @@ test('text-color', async () => {
42
48
resolve ( __dirname , './test.sketch' ) ,
43
49
Assistant ,
44
50
)
45
- const textColorViolations = violations . find (
51
+ const textColorViolations = violations . filter (
46
52
( v ) => v . ruleName === 'lightning-design-system-linter/text-color' ,
47
- ) ?. objects
53
+ )
48
54
49
55
expect ( textColorViolations ?. length ) . toBe ( 1 )
50
- expect ( textColorViolations ? textColorViolations [ 0 ] . name : null ) . toBe ( 'Bad Text' )
56
+
57
+ expect ( textColorViolations ? textColorViolations [ 0 ] . objects [ 0 ] . name : null ) . toBe ( 'Bad Text' )
51
58
expect ( ruleErrors ) . toHaveLength ( 0 )
52
59
} )
53
60
@@ -56,12 +63,12 @@ test('text-font', async () => {
56
63
resolve ( __dirname , './test.sketch' ) ,
57
64
Assistant ,
58
65
)
59
- const fontFamilyViolations = violations . find (
66
+ const fontFamilyViolations = violations . filter (
60
67
( v ) => v . ruleName === 'lightning-design-system-linter/font' ,
61
- ) ?. objects
68
+ )
62
69
63
70
expect ( fontFamilyViolations ?. length ) . toBe ( 1 )
64
- expect ( fontFamilyViolations ? fontFamilyViolations [ 0 ] . name : null ) . toBe ( 'Bad Text' )
71
+ expect ( fontFamilyViolations ? fontFamilyViolations [ 0 ] . objects [ 0 ] . name : null ) . toBe ( 'Bad Text' )
65
72
expect ( ruleErrors ) . toHaveLength ( 0 )
66
73
} )
67
74
@@ -70,12 +77,12 @@ test('text-size', async () => {
70
77
resolve ( __dirname , './test.sketch' ) ,
71
78
Assistant ,
72
79
)
73
- const fontSizeViolations = violations . find (
80
+ const fontSizeViolations = violations . filter (
74
81
( v ) => v . ruleName === 'lightning-design-system-linter/text-size' ,
75
- ) ?. objects
82
+ )
76
83
77
84
expect ( fontSizeViolations ?. length ) . toBe ( 1 )
78
- expect ( fontSizeViolations ? fontSizeViolations [ 0 ] . name : null ) . toBe ( 'Bad Text' )
85
+ expect ( fontSizeViolations ? fontSizeViolations [ 0 ] . objects [ 0 ] . name : null ) . toBe ( 'Bad Text' )
79
86
expect ( ruleErrors ) . toHaveLength ( 0 )
80
87
} )
81
88
@@ -86,21 +93,22 @@ test('getBackgroundColors', async () => {
86
93
. concat ( standardIconTokens . properties )
87
94
. concat ( customIconTokens . properties )
88
95
89
- expect ( getBackgroundColors ( ) ) . toHaveLength ( tokens . length )
96
+ expect ( getBackgroundColors ( ) ) . toHaveLength ( tokens . length + newPaletteLength )
90
97
} )
91
98
92
99
test ( 'getBorderColors' , async ( ) => {
93
100
const tokens = primitiveTokens . properties . filter (
94
101
( p ) => p . category === 'border-color' || p . category === 'color' ,
95
102
)
96
- expect ( getBorderColors ( ) ) . toHaveLength ( tokens . length )
103
+ expect ( getBorderColors ( ) ) . toHaveLength ( tokens . length + newPaletteLength )
97
104
} )
98
105
99
106
test ( 'getTextColors' , async ( ) => {
100
107
const tokens = primitiveTokens . properties . filter (
101
108
( p ) => p . category === 'text-color' || p . category === 'color' ,
102
109
)
103
- expect ( getTextColors ( ) ) . toHaveLength ( tokens . length )
110
+
111
+ expect ( getTextColors ( ) ) . toHaveLength ( tokens . length + newPaletteLength )
104
112
} )
105
113
106
114
test ( 'getFontSizes' , async ( ) => {
0 commit comments