|
| 1 | +/* |
| 2 | + * Copyright 2025 Adobe. All rights reserved. |
| 3 | + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. You may obtain a copy |
| 5 | + * of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | + * |
| 7 | + * Unless required by applicable law or agreed to in writing, software distributed under |
| 8 | + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS |
| 9 | + * OF ANY KIND, either express or implied. See the License for the specific language |
| 10 | + * governing permissions and limitations under the License. |
| 11 | + */ |
| 12 | +import { numberLocales } from '@spectrum-charts/locales'; |
| 13 | + |
| 14 | +import { getVegaEmbedOptions } from './vegaEmbedUtils'; |
| 15 | + |
| 16 | +describe('getVegaEmbedOptions()', () => { |
| 17 | + it('should return the correct options', () => { |
| 18 | + const options = getVegaEmbedOptions({}); |
| 19 | + expect(options).toHaveProperty('actions', false); |
| 20 | + expect(options).toHaveProperty('ast', true); |
| 21 | + expect(options).toHaveProperty('expressionFunctions'); |
| 22 | + expect(options).toHaveProperty('formatLocale'); |
| 23 | + expect(options).toHaveProperty('height', 400); |
| 24 | + expect(options).toHaveProperty('width', 600); |
| 25 | + expect(options).toHaveProperty('padding', 0); |
| 26 | + }); |
| 27 | + it('should use the correct color scheme', () => { |
| 28 | + let options = getVegaEmbedOptions({ colorScheme: 'dark' }); |
| 29 | + expect(options?.config?.text?.fill).toEqual('rgb(235, 235, 235)'); |
| 30 | + options = getVegaEmbedOptions({ colorScheme: 'light' }); |
| 31 | + expect(options?.config?.text?.fill).toEqual('rgb(34, 34, 34)'); |
| 32 | + }); |
| 33 | + it('should default to en-US', () => { |
| 34 | + const enLocale = numberLocales['en-US']; |
| 35 | + const options = getVegaEmbedOptions({}); |
| 36 | + expect(options?.formatLocale).toEqual(enLocale); |
| 37 | + }); |
| 38 | + it('should use the correct locale if provided', () => { |
| 39 | + const frLocale = numberLocales['fr-FR']; |
| 40 | + const options = getVegaEmbedOptions({ locale: 'fr-FR' }); |
| 41 | + expect(options?.formatLocale).toEqual(frLocale); |
| 42 | + }); |
| 43 | +}); |
0 commit comments