@@ -3,19 +3,30 @@ import { google } from 'googleapis'
33import * as mod from '../src/google'
44
55const fakeUsersResponse = [
6- { customSchemas : { Accounts : { github : [ { value : 'chrisns' } ] } } } ,
6+ { customSchemas : { Accounts : { github : [ { value : 'chrisns' } ] } } , suspended : false , archived : false } ,
77 {
88 customSchemas : {
99 Accounts : { github : [ { value : 'Foo' } , , { value : 'tar' } ] } ,
1010 } ,
11+ suspended : false ,
12+ archived : false ,
1113 } ,
1214 {
1315 customSchemas : {
1416 Accounts : { github : [ { value : 'foo' } , { value : 'bar' } ] } ,
1517 } ,
18+ suspended : false ,
19+ archived : false ,
1620 } ,
1721]
1822
23+ const fakeUsersResponseWithSuspended = [
24+ { customSchemas : { Accounts : { github : [ { value : 'activeuser' } ] } } , suspended : false , archived : false } ,
25+ { customSchemas : { Accounts : { github : [ { value : 'suspendeduser' } ] } } , suspended : true , archived : false } ,
26+ { customSchemas : { Accounts : { github : [ { value : 'archiveduser' } ] } } , suspended : false , archived : true } ,
27+ { customSchemas : { Accounts : { github : [ { value : 'botharchivedandsuspended' } ] } } , suspended : true , archived : true } ,
28+ ]
29+
1930describe ( 'google integration' , ( ) => {
2031 beforeEach ( ( ) => {
2132 process . env . GOOGLE_EMAIL_ADDRESS = 'hello@example.com'
@@ -49,12 +60,26 @@ describe('google integration', () => {
4960 it ( 'formatUserList bad' , ( ) =>
5061 expect (
5162 mod . formatUserList ( [
52- { } ,
53- { customSchemas : { } } ,
54- { customSchemas : { Accounts : { } } } ,
55- { customSchemas : { Accounts : { github : [ ] } } } ,
56- { customSchemas : { Accounts : { github : [ { } ] } } } ,
57- { customSchemas : { Accounts : { github : [ { value : 'chrisns' } ] } } } ,
63+ { suspended : false , archived : false } ,
64+ { customSchemas : { } , suspended : false , archived : false } ,
65+ { customSchemas : { Accounts : { } } , suspended : false , archived : false } ,
66+ { customSchemas : { Accounts : { github : [ ] } } , suspended : false , archived : false } ,
67+ { customSchemas : { Accounts : { github : [ { } ] } } , suspended : false , archived : false } ,
68+ { customSchemas : { Accounts : { github : [ { value : 'chrisns' } ] } } , suspended : false , archived : false } ,
5869 ] ) ,
5970 ) . toMatchSnapshot ( ) )
71+
72+ it ( 'formatUserList filters out suspended users' , ( ) => {
73+ const result = mod . formatUserList ( fakeUsersResponseWithSuspended )
74+ expect ( result ) . toEqual ( new Set ( [ 'activeuser' ] ) )
75+ } )
76+
77+ it ( 'formatUserList filters out archived users' , ( ) => {
78+ const users = [
79+ { customSchemas : { Accounts : { github : [ { value : 'active' } ] } } , suspended : false , archived : false } ,
80+ { customSchemas : { Accounts : { github : [ { value : 'archived' } ] } } , suspended : false , archived : true } ,
81+ ]
82+ const result = mod . formatUserList ( users )
83+ expect ( result ) . toEqual ( new Set ( [ 'active' ] ) )
84+ } )
6085} )
0 commit comments