99 * OF ANY KIND, either express or implied. See the License for the specific language
1010 * governing permissions and limitations under the License.
1111 */
12- import { Scale , ScaleField } from 'vega' ;
12+ import { Scale } from 'vega' ;
1313
1414import { COLOR_SCALE , DEFAULT_COLOR , LINE_TYPE_SCALE , SYMBOL_SIZE_SCALE , TABLE } from '@spectrum-charts/constants' ;
1515
16- import { getFacets , getFacetsFromKeys , getFieldName } from './legendFacetUtils' ;
17-
16+ import { getFacets , getFacetsFromKeys } from './legendFacetUtils' ;
1817
1918describe ( 'getFacets()' , ( ) => {
2019 test ( 'should correctly identify continuous and categorical facets' , ( ) => {
@@ -38,8 +37,6 @@ describe('getFacets()', () => {
3837 expect ( ordinalFacets ) . toHaveLength ( 1 ) ;
3938 expect ( continuousFacets ) . toHaveLength ( 1 ) ;
4039 } ) ;
41-
42-
4340} ) ;
4441
4542describe ( 'getFacetsFromKeys()' , ( ) => {
@@ -67,69 +64,4 @@ describe('getFacetsFromKeys()', () => {
6764 expect ( facets . ordinalFacets ) . toHaveLength ( 1 ) ;
6865 expect ( facets . continuousFacets ) . toHaveLength ( 0 ) ;
6966 } ) ;
70-
71-
72- } ) ;
73-
74- describe ( 'getFieldName()' , ( ) => {
75- test ( 'should return string field as is' , ( ) => {
76- expect ( getFieldName ( 'category' ) ) . toBe ( 'category' ) ;
77- expect ( getFieldName ( 'series' ) ) . toBe ( 'series' ) ;
78- expect ( getFieldName ( '' ) ) . toBe ( '' ) ;
79- } ) ;
80-
81- test ( 'should extract field name from object with field property' , ( ) => {
82- expect ( getFieldName ( { field : 'category' } as unknown as ScaleField ) ) . toBe ( 'category' ) ;
83- expect ( getFieldName ( { field : 'series' } as unknown as ScaleField ) ) . toBe ( 'series' ) ;
84- expect ( getFieldName ( { field : '' } as unknown as ScaleField ) ) . toBe ( '' ) ;
85- } ) ;
86-
87- test ( 'should extract signal name from object with signal property' , ( ) => {
88- expect ( getFieldName ( { signal : 'category' } as unknown as ScaleField ) ) . toBe ( 'category' ) ;
89- expect ( getFieldName ( { signal : 'series' } as unknown as ScaleField ) ) . toBe ( 'series' ) ;
90- expect ( getFieldName ( { signal : '' } as unknown as ScaleField ) ) . toBe ( '' ) ;
91- } ) ;
92-
93- test ( 'should handle undefined input' , ( ) => {
94- expect ( getFieldName ( undefined ) ) . toBe ( 'undefined' ) ;
95- } ) ;
96-
97- test ( 'should handle null input' , ( ) => {
98- expect ( getFieldName ( null as unknown as ScaleField ) ) . toBe ( 'null' ) ;
99- } ) ;
100-
101- test ( 'should handle other object types with toString fallback' , ( ) => {
102- const obj = { toString : ( ) => 'custom object' } ;
103- expect ( getFieldName ( obj as unknown as ScaleField ) ) . toBe ( 'custom object' ) ;
104- } ) ;
105-
106- test ( 'should handle object with both field and signal properties' , ( ) => {
107- // Should prioritize field over signal
108- expect ( getFieldName ( { field : 'category' , signal : 'series' } as unknown as ScaleField ) ) . toBe ( 'category' ) ;
109- } ) ;
110-
111- test ( 'should handle object with non-string field property' , ( ) => {
112- expect ( getFieldName ( { field : 123 } as unknown as ScaleField ) ) . toBe ( '[object Object]' ) ;
113- } ) ;
114-
115- test ( 'should handle object with non-string signal property' , ( ) => {
116- expect ( getFieldName ( { signal : 456 } as unknown as ScaleField ) ) . toBe ( '[object Object]' ) ;
117- } ) ;
118-
119- test ( 'should handle empty object' , ( ) => {
120- expect ( getFieldName ( { } as unknown as ScaleField ) ) . toBe ( '[object Object]' ) ;
121- } ) ;
122-
123- test ( 'should handle array input' , ( ) => {
124- expect ( getFieldName ( [ 'category' ] as unknown as ScaleField ) ) . toBe ( 'category' ) ;
125- } ) ;
126-
127- test ( 'should handle number input' , ( ) => {
128- expect ( getFieldName ( 123 as unknown as ScaleField ) ) . toBe ( '123' ) ;
129- } ) ;
130-
131- test ( 'should handle boolean input' , ( ) => {
132- expect ( getFieldName ( true as unknown as ScaleField ) ) . toBe ( 'true' ) ;
133- expect ( getFieldName ( false as unknown as ScaleField ) ) . toBe ( 'false' ) ;
134- } ) ;
13567} ) ;
0 commit comments