* Add linter rules for import order and type member delimiters * Remove unneeded group * Group all app/* imports before the internal imports * Move app/ imports before parent imports * Separate @node_modules imports into a different group * Substitute app paths by aliases * Fix @node_modules import order and add test related modules * Add aliases for types and test, and group import types
82 lines
2.5 KiB
JavaScript
82 lines
2.5 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import assert from 'assert';
|
|
|
|
import * as Selectors from '@mm-redux/selectors/entities/threads';
|
|
import deepFreezeAndThrowOnMutation from '@mm-redux/utils/deep_freeze';
|
|
import TestHelper from '@test/test_helper';
|
|
|
|
describe('Selectors.Threads.getThreadOrderInCurrentTeam', () => {
|
|
const team1 = TestHelper.fakeTeamWithId();
|
|
const team2 = TestHelper.fakeTeamWithId();
|
|
|
|
it('should return threads order in current team based on last reply time', () => {
|
|
const user = TestHelper.fakeUserWithId();
|
|
|
|
const profiles = {
|
|
[user.id]: user,
|
|
};
|
|
|
|
const testState = deepFreezeAndThrowOnMutation({
|
|
entities: {
|
|
users: {
|
|
currentUserId: user.id,
|
|
profiles,
|
|
},
|
|
teams: {
|
|
currentTeamId: team1.id,
|
|
},
|
|
threads: {
|
|
threads: {
|
|
a: {last_reply_at: 1, is_following: true},
|
|
b: {last_reply_at: 2, is_following: true},
|
|
},
|
|
threadsInTeam: {
|
|
[team1.id]: ['a', 'b'],
|
|
[team2.id]: ['c', 'd'],
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
assert.deepStrictEqual(Selectors.getThreadOrderInCurrentTeam(testState), ['b', 'a']);
|
|
});
|
|
});
|
|
|
|
describe('Selectors.Threads.getThreadsInCurrentTeam', () => {
|
|
const team1 = TestHelper.fakeTeamWithId();
|
|
const team2 = TestHelper.fakeTeamWithId();
|
|
|
|
it('should return threads in current team', () => {
|
|
const user = TestHelper.fakeUserWithId();
|
|
|
|
const profiles = {
|
|
[user.id]: user,
|
|
};
|
|
|
|
const testState = deepFreezeAndThrowOnMutation({
|
|
entities: {
|
|
users: {
|
|
currentUserId: user.id,
|
|
profiles,
|
|
},
|
|
teams: {
|
|
currentTeamId: team1.id,
|
|
},
|
|
threads: {
|
|
threads: {
|
|
a: {},
|
|
b: {},
|
|
},
|
|
threadsInTeam: {
|
|
[team1.id]: ['a', 'b'],
|
|
[team2.id]: ['c', 'd'],
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
assert.deepStrictEqual(Selectors.getThreadsInCurrentTeam(testState), ['a', 'b']);
|
|
});
|
|
});
|