Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
Adds new selector group tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkraft committed May 6, 2019
1 parent b020c4f commit 619de88
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions src/selectors/entities/groups.test.js
Expand Up @@ -10,7 +10,12 @@ describe('Selectors.Groups', () => {
const teamID = 'c6ubwm63apgftbjs71enbjjpsh';
const expectedAssociatedGroupID1 = 'xh585kyz3tn55q6ipfo57btwnc';
const expectedAssociatedGroupID2 = 'emdwu98u6jg9xfn9p5zu48bojo';
const associatedGroupIDs = [expectedAssociatedGroupID1, expectedAssociatedGroupID2];
const teamAssociatedGroupIDs = [expectedAssociatedGroupID1, expectedAssociatedGroupID2];

const channelID = 'c6ubwm63apgftbjs71enbjjpzz';
const expectedAssociatedGroupID3 = 'xos794c6tfb57eog481acokozc';
const expectedAssociatedGroupID4 = 'tnd8zod9f3fdtqosxjmhwucbth';
const channelAssociatedGroupIDs = [expectedAssociatedGroupID3, expectedAssociatedGroupID4];
const testState = deepFreezeAndThrowOnMutation({
entities: {
groups: {
Expand All @@ -30,8 +35,8 @@ describe('Selectors.Groups', () => {
has_syncables: false,
member_count: 2,
},
xos794c6tfb57eog481acokozc: {
id: 'xos794c6tfb57eog481acokozc',
[expectedAssociatedGroupID3]: {
id: expectedAssociatedGroupID3,
name: '5mte953ncbfpunpr3zmtopiwbo',
display_name: 'developers',
description: '',
Expand All @@ -43,14 +48,14 @@ describe('Selectors.Groups', () => {
has_syncables: false,
member_count: 5,
},
tnd8zod9f3fdtqosxjmhwucbth: {
id: 'tnd8zod9f3fdtqosxjmhwucbth',
[expectedAssociatedGroupID4]: {
id: [expectedAssociatedGroupID4],
name: 'nobctj4brfgtpj3a1peiyq47tc',
display_name: 'engineering',
description: '',
source: 'ldap',
remote_id: 'engineering',
create_at: 1553808971099,
remote_id: 'engineering',
update_at: 1553808971099,
delete_at: 0,
has_syncables: false,
Expand All @@ -73,7 +78,12 @@ describe('Selectors.Groups', () => {
},
teams: {
groupsAssociatedToTeam: {
[teamID]: associatedGroupIDs,
[teamID]: teamAssociatedGroupIDs,
},
},
channels: {
groupsAssociatedToChannel: {
[channelID]: channelAssociatedGroupIDs,
},
},
},
Expand All @@ -88,7 +98,20 @@ describe('Selectors.Groups', () => {
});

it('getGroupsNotAssociatedToTeam', () => {
const expected = Object.entries(testState.entities.groups.groups).filter(([groupID]) => !associatedGroupIDs.includes(groupID)).map(([, group]) => group);
const expected = Object.entries(testState.entities.groups.groups).filter(([groupID]) => !teamAssociatedGroupIDs.includes(groupID)).map(([, group]) => group);
assert.deepEqual(Selectors.getGroupsNotAssociatedToTeam(testState, teamID), expected);
});

it('getGroupsAssociatedToChannel', () => {
const expected = [
testState.entities.groups.groups[expectedAssociatedGroupID3],
testState.entities.groups.groups[expectedAssociatedGroupID4],
];
assert.deepEqual(Selectors.getGroupsAssociatedToChannel(testState, channelID), expected);
});

it('getGroupsNotAssociatedToChannel', () => {
const expected = Object.entries(testState.entities.groups.groups).filter(([groupID]) => !channelAssociatedGroupIDs.includes(groupID)).map(([, group]) => group);
assert.deepEqual(Selectors.getGroupsNotAssociatedToChannel(testState, channelID), expected);
});
});

0 comments on commit 619de88

Please sign in to comment.