File tree Expand file tree Collapse file tree 4 files changed +67
-1
lines changed Expand file tree Collapse file tree 4 files changed +67
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { env } from "../src/typeDefinitions/default.types" ;
2
+ import {
3
+ RDS_BASE_API_URL ,
4
+ RDS_BASE_STAGING_API_URL ,
5
+ RDS_BASE_DEVELOPMENT_API_URL ,
6
+ } from "../src/constants/urls" ;
7
+
8
+ const config = ( env : env ) => {
9
+ const environment = { RDS_BASE_API_URL : "" } ;
10
+
11
+ switch ( env . CURRENT_ENVIRONMENT ) {
12
+ case "production" :
13
+ environment . RDS_BASE_API_URL = RDS_BASE_API_URL ;
14
+ break ;
15
+
16
+ case "staging" :
17
+ environment . RDS_BASE_API_URL = RDS_BASE_STAGING_API_URL ;
18
+ break ;
19
+
20
+ default :
21
+ environment . RDS_BASE_API_URL = RDS_BASE_DEVELOPMENT_API_URL ;
22
+ }
23
+
24
+ return environment ;
25
+ } ;
26
+
27
+ export default config ;
Original file line number Diff line number Diff line change 1
- export const RDS_API_BASE_URL = "https://api.realdevsquad.com" ;
1
+ export const RDS_BASE_API_URL = "https://api.realdevsquad.com" ;
2
+ export const RDS_BASE_STAGING_API_URL = "https://staging-api.realdevsquad.com" ;
3
+ export const RDS_BASE_DEVELOPMENT_API_URL = "http://localhost:3000" ; // If needed, modify the URL to your local API server
4
+
2
5
export const DISCORD_BASE_URL = "https://discord.com/api/v10" ;
3
6
export const VERIFICATION_SITE_URL = "https://my.realdevsquad.com" ;
Original file line number Diff line number Diff line change
1
+ export const environment = [
2
+ {
3
+ CURRENT_ENVIRONMENT : "production" ,
4
+ } ,
5
+ {
6
+ CURRENT_ENVIRONMENT : "staging" ,
7
+ } ,
8
+ {
9
+ CURRENT_ENVIRONMENT : "" ,
10
+ } ,
11
+ ] ;
Original file line number Diff line number Diff line change
1
+ import config from "../../../config/config" ;
2
+ import { environment } from "../../fixtures/config" ;
3
+ import {
4
+ RDS_BASE_API_URL ,
5
+ RDS_BASE_DEVELOPMENT_API_URL ,
6
+ RDS_BASE_STAGING_API_URL ,
7
+ } from "../../../src/constants/urls" ;
8
+
9
+ describe ( "Test config function" , ( ) => {
10
+ it ( "Should return production config environment" , ( ) => {
11
+ expect ( config ( environment [ 0 ] ) . RDS_BASE_API_URL ) . toBe ( RDS_BASE_API_URL ) ;
12
+ } ) ;
13
+
14
+ it ( "Should return staging config environment" , ( ) => {
15
+ expect ( config ( environment [ 1 ] ) . RDS_BASE_API_URL ) . toBe (
16
+ RDS_BASE_STAGING_API_URL
17
+ ) ;
18
+ } ) ;
19
+
20
+ it ( "Should return default config environment" , ( ) => {
21
+ expect ( config ( environment [ 2 ] ) . RDS_BASE_API_URL ) . toBe (
22
+ RDS_BASE_DEVELOPMENT_API_URL
23
+ ) ;
24
+ } ) ;
25
+ } ) ;
You can’t perform that action at this time.
0 commit comments