@@ -11,6 +11,39 @@ jest.mock('@actions/core', () => ({
1111 endGroup : jest . fn ( )
1212} ) )
1313
14+ describe ( 'set output post filtering' , ( ) => {
15+ test ( 'correctly sets output' , ( ) => {
16+ const yaml = `
17+ backend:
18+ - '!(**/*.tsx|**/*.less)'
19+ `
20+ const filter = new Filter ( yaml )
21+ const files = modified ( [ 'config/settings.yml' ] )
22+ const match = filter . match ( files )
23+ exportResults ( match , 'none' )
24+
25+ expect ( core . setOutput ) . toHaveBeenCalledWith ( 'changes' , '["backend"]' )
26+ } )
27+ test ( 'correctly filters out shared from output' , ( ) => {
28+ const yaml = `
29+ shared: &shared
30+ - common/**/*
31+ - config/**/*
32+ src:
33+ - *shared
34+ - src/**/*
35+ backend:
36+ - '!(**/*.tsx|**/*.less)'
37+ `
38+ const filter = new Filter ( yaml )
39+ const files = modified ( [ 'config/settings.yml' ] )
40+ const match = filter . match ( files )
41+ exportResults ( match , 'none' )
42+
43+ expect ( core . setOutput ) . toHaveBeenCalledWith ( 'changes' , '["src","backend"]' )
44+ } )
45+ } )
46+
1447describe ( 'yaml filter parsing tests' , ( ) => {
1548 test ( 'throws if yaml is not a dictionary' , ( ) => {
1649 const yaml = 'not a dictionary'
@@ -170,9 +203,6 @@ describe('matching tests', () => {
170203 const filter = new Filter ( yaml )
171204 const files = modified ( [ 'config/settings.yml' ] )
172205 const match = filter . match ( files )
173- exportResults ( match , 'none' )
174-
175- expect ( core . setOutput ) . toHaveBeenCalledWith ( 'changes' , '["src"]' )
176206 expect ( match . src ) . toEqual ( files )
177207 } )
178208} )
0 commit comments