forked from mattermost/mattermost
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MM-61198: react-hooks-testing-library and renderHookWithContext (matt…
- Loading branch information
1 parent
da2a84e
commit 3ac1c98
Showing
4 changed files
with
147 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import type {DeepPartial} from '@mattermost/types/utilities'; | ||
|
||
import {renderHookWithContext} from 'tests/react_testing_utils'; | ||
import {TestHelper} from 'utils/test_helper'; | ||
|
||
import type {GlobalState} from 'types/store'; | ||
|
||
import {useThreadRouting} from './hooks'; | ||
|
||
describe('components/threading/hooks', () => { | ||
const mockUser = TestHelper.getUserMock(); | ||
const mockTeam = TestHelper.getTeamMock(); | ||
|
||
const mockState: DeepPartial<GlobalState> = { | ||
entities: { | ||
users: { | ||
currentUserId: mockUser.id, | ||
}, | ||
teams: { | ||
currentTeamId: mockTeam.id, | ||
}, | ||
}, | ||
}; | ||
|
||
describe('useThreadRouting', () => { | ||
test('should indicate current team and user', () => { | ||
const {result} = renderHookWithContext(() => useThreadRouting(), mockState); | ||
|
||
expect(result.current.currentUserId).toBe(mockUser.id); | ||
expect(result.current.currentTeamId).toBe(mockTeam.id); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.