Fixes broken flow
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { getBrowserLocale, getBrowserTimezone } from '../BrowserHelper';
|
||||
|
||||
describe('getBrowserLocale', () => {
|
||||
it('should return the correct locale code when an exact match is found', () => {
|
||||
// Mock window.navigator.language
|
||||
Object.defineProperty(window.navigator, 'language', {
|
||||
value: 'en-US',
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
const languages = [{ iso_639_1_code: 'en' }, { iso_639_1_code: 'en-US' }];
|
||||
expect(getBrowserLocale(languages)).toBe('en-US');
|
||||
});
|
||||
|
||||
it('should return the correct locale code when only a partial match is found', () => {
|
||||
Object.defineProperty(window.navigator, 'language', {
|
||||
value: 'en-GB',
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
const languages = [{ iso_639_1_code: 'en' }, { iso_639_1_code: 'fr' }];
|
||||
expect(getBrowserLocale(languages)).toBe('en');
|
||||
});
|
||||
|
||||
it('should return undefined when no match is found', () => {
|
||||
Object.defineProperty(window.navigator, 'language', {
|
||||
value: 'es-ES',
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
const languages = [{ iso_639_1_code: 'en' }, { iso_639_1_code: 'fr' }];
|
||||
expect(getBrowserLocale(languages)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getBrowserTimezone', () => {
|
||||
it('should return the current browser timezone', () => {
|
||||
// This test assumes the environment's timezone is set.
|
||||
// It's a basic test as getBrowserTimezone relies on Intl API.
|
||||
const timezone = getBrowserTimezone();
|
||||
expect(timezone).toBe(Intl.DateTimeFormat().resolvedOptions().timeZone);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
import { findMatchingOption, findCompanySizeMatch } from '../OnboardingHelper';
|
||||
|
||||
describe('findMatchingOption', () => {
|
||||
const options = [{ value: 'option1' }, { value: 'option2' }];
|
||||
|
||||
it('should return the matching option', () => {
|
||||
expect(findMatchingOption('option1', options, 'default')).toBe('option1');
|
||||
});
|
||||
|
||||
it('should return the default value when no match is found', () => {
|
||||
expect(findMatchingOption('nonExistingOption', options, 'default')).toBe(
|
||||
'default'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findCompanySizeMatch', () => {
|
||||
const mockCompanySizeOptions = [
|
||||
{ value: '1-10' },
|
||||
{ value: '11-50' },
|
||||
{ value: '51-500' },
|
||||
{ value: '501-1000' },
|
||||
{ value: '1001+' },
|
||||
];
|
||||
|
||||
it('should return the correct company size range', () => {
|
||||
const size = 25;
|
||||
expect(findCompanySizeMatch(size, mockCompanySizeOptions)).toBe('11-50');
|
||||
});
|
||||
|
||||
it('should return the first company size range when no match is found', () => {
|
||||
const size = 1500;
|
||||
expect(findCompanySizeMatch(size, mockCompanySizeOptions)).toBe('1-10');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user