* Add tests to client/rest/users * Add tests to client/rest/channels * Add tests to client/rest/posts * Add tests to client/rest/teams * Add tests to client/rest/general * Minor clean-up * Add tests to client/rest/file * Add tests to client/rest/threads * Add tests to client/rest/emojis * Add tests to client/rest/integrations * Add tests to client/rest/categories * Add tests to client/rest/groups * Add tests to client/rest/channel_bookmark * Add tests to client/rest/preferences * Add tests to client/rest/tos * Add tests to client/rest/nps and client/rest/plugins * Minor clean-up * Fix type error with proper client.searchFiles definition * add more test to cover 100% * add teamId test * improve users test --------- Co-authored-by: Rahim Rahman <rahim.rahman@mattermost.com>
62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import TestHelper from '@test/test_helper';
|
|
|
|
import type ClientBase from './base';
|
|
import type {ClientCategoriesMix} from './categories';
|
|
|
|
describe('ClientCategories', () => {
|
|
let client: ClientCategoriesMix & ClientBase;
|
|
|
|
beforeAll(() => {
|
|
client = TestHelper.createClient();
|
|
client.doFetch = jest.fn();
|
|
});
|
|
|
|
test('getCategories', async () => {
|
|
const userId = 'user_id';
|
|
const teamId = 'team_id';
|
|
await client.getCategories(userId, teamId);
|
|
|
|
expect(client.doFetch).toHaveBeenCalledWith(
|
|
client.getCategoriesRoute(userId, teamId),
|
|
{method: 'get', groupLabel: undefined},
|
|
);
|
|
});
|
|
|
|
test('getCategoriesOrder', async () => {
|
|
const userId = 'user_id';
|
|
const teamId = 'team_id';
|
|
await client.getCategoriesOrder(userId, teamId);
|
|
|
|
expect(client.doFetch).toHaveBeenCalledWith(
|
|
client.getCategoriesOrderRoute(userId, teamId),
|
|
{method: 'get'},
|
|
);
|
|
});
|
|
|
|
test('getCategory', async () => {
|
|
const userId = 'user_id';
|
|
const teamId = 'team_id';
|
|
const categoryId = 'category_id';
|
|
await client.getCategory(userId, teamId, categoryId);
|
|
|
|
expect(client.doFetch).toHaveBeenCalledWith(
|
|
client.getCategoryRoute(userId, teamId, categoryId),
|
|
{method: 'get'},
|
|
);
|
|
});
|
|
|
|
test('updateChannelCategories', async () => {
|
|
const userId = 'user_id';
|
|
const teamId = 'team_id';
|
|
const categories = [{id: 'category_id', channel_ids: ['channel_id']}] as CategoryWithChannels[];
|
|
await client.updateChannelCategories(userId, teamId, categories);
|
|
|
|
expect(client.doFetch).toHaveBeenCalledWith(
|
|
client.getCategoriesRoute(userId, teamId),
|
|
{method: 'put', body: categories},
|
|
);
|
|
});
|
|
});
|