4
4
} from '../../lib/index.js'
5
5
6
6
describe ( 'audit log event fitering' , ( ) => {
7
- it ( 'match single allowlist value' , ( ) => {
7
+ it ( 'matches single allowlist value' , ( ) => {
8
8
const eventsToProcess = [
9
9
{
10
10
action : 'repo.create' ,
@@ -17,7 +17,7 @@ describe('audit log event fitering', () => {
17
17
expect ( filteredEvents [ 0 ] . action ) . toEqual ( 'repo.create' )
18
18
} )
19
19
20
- it ( 'match multiple allowlist values' , ( ) => {
20
+ it ( 'matches multiple allowlist values' , ( ) => {
21
21
const eventsToProcess = [
22
22
{
23
23
action : 'repo.create' ,
@@ -36,7 +36,7 @@ describe('audit log event fitering', () => {
36
36
expect ( filteredEvents . length ) . toEqual ( 2 )
37
37
} )
38
38
39
- it ( 'non-match allowlist value' , ( ) => {
39
+ it ( 'does not match non-matching allowlist value' , ( ) => {
40
40
const eventsToProcess = [
41
41
{
42
42
action : 'repo.create' ,
@@ -49,7 +49,7 @@ describe('audit log event fitering', () => {
49
49
expect ( filteredEvents . length ) . toBe ( 0 )
50
50
} )
51
51
52
- it ( 'ghes filter and update multiple ghes versions' , ( ) => {
52
+ it ( 'ghes filters and updates multiple ghes versions' , ( ) => {
53
53
const eventsToProcess = [
54
54
{
55
55
action : 'repo.create' ,
@@ -100,4 +100,34 @@ describe('audit log event fitering', () => {
100
100
expect ( getActions ( 'ghes-3.11' ) . includes ( 'repo.create' ) ) . toBe ( true )
101
101
expect ( auditLogPage in currentEvents [ 'ghes-3.12' ] ) . toBeFalsy ( )
102
102
} )
103
+
104
+ it ( 'gets the correct event fields data' , ( ) => {
105
+ const eventsToProcess = [
106
+ {
107
+ action : 'repo.create' ,
108
+ _allowlists : [ 'user' ] ,
109
+ description : 'repo was created' ,
110
+ fields : [ 'beep' ] ,
111
+ ghes : {
112
+ '3.10' : {
113
+ _allowlists : [ 'user' ] ,
114
+ fields : [ 'boop' ] ,
115
+ } ,
116
+ } ,
117
+ } ,
118
+ ]
119
+ const filteredEvents = filterByAllowlistValues ( eventsToProcess , 'user' )
120
+ expect ( filteredEvents [ 0 ] . fields ) . toContain ( 'beep' )
121
+
122
+ const currentEvents = { }
123
+ const auditLogPage = 'user'
124
+ filterAndUpdateGhesDataByAllowlistValues (
125
+ eventsToProcess ,
126
+ 'user' ,
127
+ currentEvents ,
128
+ { } ,
129
+ auditLogPage ,
130
+ )
131
+ expect ( currentEvents [ 'ghes-3.10' ] . user [ 0 ] . fields ) . toContain ( 'boop' )
132
+ } )
103
133
} )
0 commit comments