@@ -4,8 +4,6 @@ import invariant from 'invariant';
44import { getOwnUser , tryGetActiveAccountState , getRealm } from '../selectors' ;
55import {
66 Role ,
7- RoleValues ,
8- type RoleT ,
97 CreatePublicOrPrivateStreamPolicy ,
108 type CreatePublicOrPrivateStreamPolicyT ,
119 CreateWebPublicStreamPolicy ,
@@ -21,18 +19,20 @@ import rootReducer from '../boot/reducers';
2119import { EVENT } from '../actionConstants' ;
2220import * as eg from './lib/exampleData' ;
2321import { EventTypes } from '../api/eventTypes' ;
24- import { objectEntries } from '../flowPonyfill' ;
2522
2623describe ( 'roleIsAtLeast' , ( ) => {
2724 const { Owner, Admin, Moderator, Member, Guest } = Role ;
2825
26+ const roleValues : $ReadOnlyArray < Role > = Array.from(Role.members());
27+
2928 // Keep this current with all possible roles, from least to most privilege.
3029 const kRolesAscending = [Guest, Member, Moderator, Admin, Owner];
31- expect ( RoleValues ) . toIncludeSameMembers ( kRolesAscending ) ;
32- expect ( RoleValues ) . toBeArrayOfSize ( kRolesAscending . length ) ;
30+ expect(roleValues ).toIncludeSameMembers(kRolesAscending);
31+ expect(roleValues ).toBeArrayOfSize(kRolesAscending.length);
3332
34- objectEntries ( Role ) . forEach ( ( [ thresholdRoleName , thresholdRole ] ) => {
35- objectEntries ( Role ) . forEach ( ( [ thisRoleName , thisRole ] ) => {
33+ const roleEntries = roleValues.map(role => [ Role . getName ( role ) , role ] ) ;
34+ roleEntries . forEach ( ( [ thresholdRoleName , thresholdRole ] ) => {
35+ roleEntries . forEach ( ( [ thisRoleName , thisRole ] ) => {
3636 const expected = kRolesAscending . indexOf ( thisRole ) >= kRolesAscending . indexOf ( thresholdRole ) ;
3737
3838 const testName = expected
@@ -86,7 +86,7 @@ describe('getCanCreatePublicStreams', () => {
8686 expected,
8787 } : {
8888 policy : CreatePublicOrPrivateStreamPolicyT ,
89- role : RoleT ,
89+ role : Role ,
9090 waitingPeriodPassed : boolean | void ,
9191 expected : boolean ,
9292 } ) => {
@@ -166,7 +166,7 @@ describe('getCanCreatePrivateStreams', () => {
166166 expected,
167167 } : {
168168 policy : CreatePublicOrPrivateStreamPolicyT ,
169- role : RoleT ,
169+ role : Role ,
170170 waitingPeriodPassed : boolean | void ,
171171 expected : boolean ,
172172 } ) => {
@@ -301,7 +301,7 @@ describe('getCanCreateWebPublicStreams', () => {
301301 expected,
302302 } : {
303303 policy : CreateWebPublicStreamPolicy ,
304- role : RoleT ,
304+ role : Role ,
305305 expected : boolean ,
306306 } ) => {
307307 const globalState = [
0 commit comments