Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add test for settings #21

Merged
merged 2 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type {Config} from '@jest/types';

const cfg: Config.InitialOptions = {
verbose: true,
preset: 'ts-jest',
testEnvironment: 'jsdom',
modulePathIgnorePatterns: ['<rootDir>/build/', '<rootDir>/node_modules/'],
};

export default cfg;
8 changes: 8 additions & 0 deletions src/libs/settings/__tests__/settings.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {DEFAULT_LOCALE_SPECIFICATION, settings} from '../settings';

describe('libs/settings', () => {
it('Default locale should be equal DEFAULT_LOCALE_SPECIFICATION', () => {
const result = settings.get('locale');
expect(result).toBe(DEFAULT_LOCALE_SPECIFICATION);
});
});
2 changes: 1 addition & 1 deletion src/libs/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Settings = {
};
type SettingKey = keyof Settings;

const DEFAULT_LOCALE_SPECIFICATION: moment.LocaleSpecification = {week: {dow: 1, doy: 7}};
export const DEFAULT_LOCALE_SPECIFICATION: moment.LocaleSpecification = {week: {dow: 1, doy: 7}};

const removeUndefinedValues = <T extends Record<string, any>>(data: T) => {
return Object.entries(data).reduce((acc, [key, value]) => {
Expand Down