@@ -3,22 +3,27 @@ import { getCorsOptions } from './get-cors-options.js'
33
44describe ( 'getCorsOptions' , ( ) => {
55 it ( 'should return CORS options with credentials enabled' , ( ) => {
6- const options = getCorsOptions ( )
6+ const options = getCorsOptions ( { } )
77 expect ( options . credentials ) . toBe ( true )
88 } )
99
10- it ( 'should allow localhost:8080 as origin' , ( ) => {
11- const options = getCorsOptions ( )
10+ it ( 'should allow localhost:8080 as default origin' , ( ) => {
11+ const options = getCorsOptions ( { } )
1212 expect ( options . origins ) . toContain ( 'http://localhost:8080' )
1313 } )
1414
15+ it ( 'should use CORS_ORIGINS env var when set' , ( ) => {
16+ const options = getCorsOptions ( { CORS_ORIGINS : 'https://app.example.com, https://admin.example.com' } )
17+ expect ( options . origins ) . toEqual ( [ 'https://app.example.com' , 'https://admin.example.com' ] )
18+ } )
19+
1520 it ( 'should include required HTTP methods' , ( ) => {
16- const options = getCorsOptions ( )
21+ const options = getCorsOptions ( { } )
1722 expect ( options . methods ) . toEqual ( expect . arrayContaining ( [ 'GET' , 'POST' , 'PATCH' , 'DELETE' ] ) )
1823 } )
1924
2025 it ( 'should include content-type in allowed headers' , ( ) => {
21- const options = getCorsOptions ( )
26+ const options = getCorsOptions ( { } )
2227 expect ( options . headers ) . toContain ( 'content-type' )
2328 } )
2429} )
0 commit comments