mattermost-mobile/app/mm-redux/selectors/entities/integrations.test.js
Miguel Alatzar 2d81b497cf [MM-23520] Port mattermost-redux (#4088)
* Remove mattermost-redux

* Move mm-redux files into app/redux

* Add @redux path to tsconfig.json

* Fix imports

* Install missing dependencies

* Fix tsc errors

* Fix i18n_utils test

* Fix more imports

* Remove redux websocket

* Fix tests

* Rename @redux

* Apply changes from mattermost-redux PR 1103

* Remove mattermost-redux mention in template

* Add missing imports

* Rename app/redux/ to app/mm-redux/

* Remove test file

* Fix fetching Sidebar GM profiles

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2020-04-17 21:12:09 -07:00

57 lines
2.2 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import assert from 'assert';
import TestHelper from 'test/test_helper';
import deepFreezeAndThrowOnMutation from '@mm-redux/utils/deep_freeze';
import {getAllCommands, getAutocompleteCommandsList, getOutgoingHooksInCurrentTeam} from './integrations';
describe('Selectors.Integrations', () => {
TestHelper.initBasic();
const team1 = TestHelper.fakeTeamWithId();
const team2 = TestHelper.fakeTeamWithId();
const hook1 = TestHelper.fakeOutgoingHookWithId(team1.id);
const hook2 = TestHelper.fakeOutgoingHookWithId(team1.id);
const hook3 = TestHelper.fakeOutgoingHookWithId(team2.id);
const hooks = {[hook1.id]: hook1, [hook2.id]: hook2, [hook3.id]: hook3};
const command1 = {id: TestHelper.generateId(), ...TestHelper.testCommand(team1.id), auto_complete: false};
const command2 = {id: TestHelper.generateId(), ...TestHelper.testCommand(team2.id)};
const command3 = TestHelper.testCommand(team1.id);
const command4 = TestHelper.testCommand(team2.id);
const commands = {[command1.id]: command1, [command2.id]: command2};
const systemCommands = {[command3.trigger]: command3, [command4.trigger]: command4};
const testState = deepFreezeAndThrowOnMutation({
entities: {
teams: {
currentTeamId: team1.id,
},
integrations: {
outgoingHooks: hooks,
commands,
systemCommands,
},
},
});
it('should return outgoing hooks in current team', () => {
const hooksInCurrentTeam1 = [hook1, hook2];
assert.deepEqual(getOutgoingHooksInCurrentTeam(testState), hooksInCurrentTeam1);
});
it('should get all commands', () => {
const commandsInState = {...commands, ...systemCommands};
assert.deepEqual(getAllCommands(testState), commandsInState);
});
it('should get all autocomplete commands by teamId', () => {
const autocompleteCommandsForTeam = [command3];
assert.deepEqual(getAutocompleteCommandsList(testState), autocompleteCommandsForTeam);
});
});