11// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22// SPDX-License-Identifier: Apache-2.0
3- import customCssProps from '../../internal/generated/custom-css-properties' ;
3+
44import { getTabContainerStyles , getTabHeaderStyles , getTabStyles } from '../styles' ;
55
66// Mock the environment module
77jest . mock ( '../../internal/environment' , ( ) => ( {
88 SYSTEM : 'core' ,
99} ) ) ;
1010
11+ const testStyles = {
12+ tabs : {
13+ borderRadius : '4px' ,
14+ borderWidth : '2px' ,
15+ fontSize : '16px' ,
16+ fontWeight : '500' ,
17+ paddingBlock : '10px' ,
18+ paddingInline : '14px' ,
19+ backgroundColor : {
20+ default : '#dbeafe' ,
21+ active : '#bfdbfe' ,
22+ disabled : '#f3f4f6' ,
23+ hover : '#eff6ff' ,
24+ } ,
25+ borderColor : {
26+ default : '#3b82f6' ,
27+ active : '#1d4ed8' ,
28+ disabled : '#93c5fd' ,
29+ hover : '#2563eb' ,
30+ } ,
31+ color : {
32+ default : '#1e40af' ,
33+ active : '#1e3a8a' ,
34+ disabled : '#93c5fd' ,
35+ hover : '#1e40af' ,
36+ } ,
37+ focusRing : {
38+ borderColor : '#3b82f6' ,
39+ borderRadius : '4px' ,
40+ borderWidth : '2px' ,
41+ } ,
42+ } ,
43+ underline : {
44+ color : '#1d4ed8' ,
45+ width : '3px' ,
46+ borderRadius : '2px' ,
47+ } ,
48+ divider : {
49+ color : '#cbd5e1' ,
50+ width : '2px' ,
51+ } ,
52+ headerDivider : {
53+ color : '#94a3b8' ,
54+ width : '3px' ,
55+ } ,
56+ } ;
57+
1158describe ( 'getTabStyles' , ( ) => {
1259 afterEach ( ( ) => {
1360 jest . resetModules ( ) ;
1461 } ) ;
1562
1663 test ( 'transforms tab styles to CSS properties' , ( ) => {
17- const tabStyles = {
18- tabs : {
19- borderRadius : '4px' ,
20- borderWidth : '2px' ,
21- fontSize : '16px' ,
22- fontWeight : '500' ,
23- paddingBlock : '10px' ,
24- paddingInline : '14px' ,
25- backgroundColor : {
26- default : '#dbeafe' ,
27- active : '#bfdbfe' ,
28- disabled : '#f3f4f6' ,
29- hover : '#eff6ff' ,
30- } ,
31- borderColor : {
32- default : '#3b82f6' ,
33- active : '#1d4ed8' ,
34- disabled : '#93c5fd' ,
35- hover : '#2563eb' ,
36- } ,
37- color : {
38- default : '#1e40af' ,
39- active : '#1e3a8a' ,
40- disabled : '#93c5fd' ,
41- hover : '#1e40af' ,
42- } ,
43- focusRing : {
44- borderColor : '#3b82f6' ,
45- borderRadius : '4px' ,
46- borderWidth : '2px' ,
47- } ,
48- } ,
49- } ;
50-
51- expect ( getTabStyles ( tabStyles ) ) . toMatchSnapshot ( ) ;
64+ expect ( getTabStyles ( testStyles ) ) . toMatchSnapshot ( ) ;
5265 } ) ;
5366
5467 test ( 'returns undefined when SYSTEM is not core' , async ( ) => {
@@ -59,13 +72,7 @@ describe('getTabStyles', () => {
5972
6073 const { getTabStyles : getTabStylesNonCore } = await import ( '../styles' ) ;
6174
62- const style = {
63- tabs : {
64- borderRadius : '4px' ,
65- } ,
66- } ;
67-
68- const result = getTabStylesNonCore ( style ) ;
75+ const result = getTabStylesNonCore ( testStyles ) ;
6976
7077 expect ( result ) . toBeUndefined ( ) ;
7178 } ) ;
@@ -77,25 +84,20 @@ describe('getTabContainerStyles', () => {
7784 } ) ;
7885
7986 test ( 'transforms container styles to CSS properties' , ( ) => {
80- const containerStyles = {
81- underline : {
82- color : '#1d4ed8' ,
83- width : '3px' ,
84- borderRadius : '2px' ,
85- } ,
86- divider : {
87- color : '#cbd5e1' ,
88- width : '2px' ,
89- } ,
90- } ;
91-
92- expect ( getTabContainerStyles ( containerStyles ) ) . toEqual ( {
93- [ customCssProps . styleTabsUnderlineColor ] : '#1d4ed8' ,
94- [ customCssProps . styleTabsUnderlineWidth ] : '3px' ,
95- [ customCssProps . styleTabsUnderlineBorderRadius ] : '2px' ,
96- [ customCssProps . styleTabsDividerColor ] : '#cbd5e1' ,
97- [ customCssProps . styleTabsDividerWidth ] : '2px' ,
98- } ) ;
87+ expect ( getTabContainerStyles ( testStyles ) ) . toMatchSnapshot ( ) ;
88+ } ) ;
89+
90+ test ( 'returns undefined when SYSTEM is not core' , async ( ) => {
91+ jest . resetModules ( ) ;
92+ jest . doMock ( '../../internal/environment' , ( ) => ( {
93+ SYSTEM : 'visual-refresh' ,
94+ } ) ) ;
95+
96+ const { getTabContainerStyles : getTabContainerStylesNonCore } = await import ( '../styles' ) ;
97+
98+ const result = getTabContainerStylesNonCore ( testStyles ) ;
99+
100+ expect ( result ) . toBeUndefined ( ) ;
99101 } ) ;
100102} ) ;
101103
@@ -105,17 +107,7 @@ describe('getTabHeaderStyles', () => {
105107 } ) ;
106108
107109 test ( 'transforms header styles to CSS properties' , ( ) => {
108- const headerStyles = {
109- headerDivider : {
110- color : '#94a3b8' ,
111- width : '3px' ,
112- } ,
113- } ;
114-
115- expect ( getTabHeaderStyles ( headerStyles ) ) . toEqual ( {
116- [ customCssProps . styleTabsHeaderDividerColor ] : '#94a3b8' ,
117- [ customCssProps . styleTabsHeaderDividerWidth ] : '3px' ,
118- } ) ;
110+ expect ( getTabHeaderStyles ( testStyles ) ) . toMatchSnapshot ( ) ;
119111 } ) ;
120112
121113 test ( 'returns undefined when SYSTEM is not core' , async ( ) => {
@@ -126,13 +118,7 @@ describe('getTabHeaderStyles', () => {
126118
127119 const { getTabHeaderStyles : getTabHeaderStylesNonCore } = await import ( '../styles' ) ;
128120
129- const style = {
130- headerDivider : {
131- color : '#94a3b8' ,
132- } ,
133- } ;
134-
135- const result = getTabHeaderStylesNonCore ( style ) ;
121+ const result = getTabHeaderStylesNonCore ( testStyles ) ;
136122
137123 expect ( result ) . toBeUndefined ( ) ;
138124 } ) ;
0 commit comments