The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/apps/meteor/client/hooks/useSortQueryOptions.spec.ts

26 lines
1.1 KiB

import { mockAppRoot } from '@rocket.chat/mock-providers';
import { renderHook } from '@testing-library/react';
import { useSortQueryOptions } from './useSortQueryOptions';
it("should return query option to sort by last message when user preference is 'activity'", () => {
const { result } = renderHook(() => useSortQueryOptions(), {
wrapper: mockAppRoot().withUserPreference('sidebarSortby', 'activity').build(),
});
expect(result.current.sort).toHaveProperty('lm', -1);
});
it("should return query option to sort by name when user preference is 'name'", () => {
const { result } = renderHook(() => useSortQueryOptions(), {
wrapper: mockAppRoot().withUserPreference('sidebarSortby', 'name').build(),
});
expect(result.current.sort).toHaveProperty('lowerCaseName', 1);
});
it("should return query option to sort by fname when user preference is 'name' and showRealName is true", () => {
const { result } = renderHook(() => useSortQueryOptions(), {
wrapper: mockAppRoot().withUserPreference('sidebarSortby', 'name').withSetting('UI_Use_Real_Name', true).build(),
});
expect(result.current.sort).toHaveProperty('lowerCaseFName', 1);
});