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

Add utils/search unit tests #8267

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Changes from 1 commit
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
29 changes: 29 additions & 0 deletions app/utils/search/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import {TabTypes, type TabType} from '.'; // Adjust path as needed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe unintentional comment line added 😄


describe('TabTypes', () => {
it('should create a mirrored object with keys equal to their values', () => {
expect(TabTypes).toEqual({
MESSAGES: 'MESSAGES',
FILES: 'FILES',
});
});

it('should allow valid keys for TabType', () => {
const validTabType1: TabType = 'MESSAGES';
const validTabType2: TabType = 'FILES';

// Ensure that validTabType1 and validTabType2 match the types in TabTypes
expect(validTabType1).toBe('MESSAGES');
expect(validTabType2).toBe('FILES');
});

it('should not allow invalid keys for TabType', () => {
// TypeScript will catch this as an error, but we can simulate with a custom runtime check
const invalidTabType = 'INVALID_TAB_TYPE' as TabType;

expect(TabTypes[invalidTabType]).toBeUndefined(); // Simulate invalid key behavior
});
});