@@ -995,162 +995,6 @@ describe('$substitute directive', () => {
995
995
expect ( parsed . toJSON ( ) ) . toEqual ( { foo : 'qa' } ) ;
996
996
} ) ;
997
997
998
- it ( 'reads object with $name' , async ( ) => {
999
- process . env . FOO = 'foo' ;
1000
-
1001
- const source = new LiteralSource ( {
1002
- foo : { $substitute : { $name : 'FOO' } } ,
1003
- } ) ;
1004
-
1005
- const parsed = await source . read ( [ substituteDirective ( ) ] ) ;
1006
-
1007
- expect ( parsed . toJSON ( ) ) . toEqual ( { foo : 'foo' } ) ;
1008
- } ) ;
1009
-
1010
- it ( 'fails with $name when not defined' , async ( ) => {
1011
- const source = new LiteralSource ( {
1012
- foo : { $substitute : { $name : 'FOO' } } ,
1013
- } ) ;
1014
-
1015
- await expect ( source . read ( [ substituteDirective ( ) ] ) ) . rejects . toThrow ( ) ;
1016
- } ) ;
1017
-
1018
- it ( 'uses $name when $fallback is defined' , async ( ) => {
1019
- process . env . FOO = 'foo' ;
1020
-
1021
- const source = new LiteralSource ( {
1022
- foo : { $substitute : { $name : 'FOO' , $fallback : 'bar' } } ,
1023
- } ) ;
1024
-
1025
- const parsed = await source . read ( [ substituteDirective ( ) ] ) ;
1026
-
1027
- expect ( parsed . toJSON ( ) ) . toEqual ( { foo : 'foo' } ) ;
1028
- } ) ;
1029
-
1030
- it ( 'uses $fallback when $name was not found' , async ( ) => {
1031
- const source = new LiteralSource ( {
1032
- foo : { $substitute : { $name : 'FOO' , $fallback : 'bar' } } ,
1033
- } ) ;
1034
-
1035
- const parsed = await source . read ( [ substituteDirective ( ) ] ) ;
1036
-
1037
- expect ( parsed . toJSON ( ) ) . toEqual ( { foo : 'bar' } ) ;
1038
- } ) ;
1039
-
1040
- it ( 'allows null value when $allowNull' , async ( ) => {
1041
- const source = new LiteralSource ( {
1042
- foo : { $substitute : { $name : 'FOO' , $fallback : null , $allowNull : true } } ,
1043
- } ) ;
1044
-
1045
- const parsed = await source . read ( [ substituteDirective ( ) ] ) ;
1046
-
1047
- expect ( parsed . toJSON ( ) ) . toEqual ( { foo : null } ) ;
1048
- } ) ;
1049
-
1050
- it ( 'does not allow number even when $allowNull' , async ( ) => {
1051
- const source = new LiteralSource ( {
1052
- foo : { $substitute : { $name : 'FOO' , $fallback : 42 , $allowNull : true } } ,
1053
- } ) ;
1054
-
1055
- await expect ( source . read ( [ substituteDirective ( ) ] ) ) . rejects . toThrow ( ) ;
1056
- } ) ;
1057
-
1058
- it ( 'parses ints' , async ( ) => {
1059
- process . env . FOO = '11' ;
1060
-
1061
- const source = new LiteralSource ( {
1062
- $substitute : { $name : 'FOO' , $parseInt : true } ,
1063
- } ) ;
1064
-
1065
- expect ( await source . readToJSON ( [ substituteDirective ( ) ] ) ) . toEqual ( 11 ) ;
1066
- } ) ;
1067
-
1068
- it ( 'fails when int is invalid' , async ( ) => {
1069
- process . env . FOO = 'not a number' ;
1070
-
1071
- const source = new LiteralSource ( {
1072
- $substitute : { $name : 'FOO' , $parseInt : true } ,
1073
- } ) ;
1074
-
1075
- await expect ( source . read ( [ substituteDirective ( ) ] ) ) . rejects . toThrow ( ) ;
1076
- } ) ;
1077
-
1078
- it ( 'parses float' , async ( ) => {
1079
- process . env . FOO = '11.2' ;
1080
-
1081
- const source = new LiteralSource ( {
1082
- $substitute : { $name : 'FOO' , $parseFloat : true } ,
1083
- } ) ;
1084
-
1085
- expect ( await source . readToJSON ( [ substituteDirective ( ) ] ) ) . toEqual ( 11.2 ) ;
1086
- } ) ;
1087
-
1088
- it ( 'fails when float is invalid' , async ( ) => {
1089
- process . env . FOO = 'not a number' ;
1090
-
1091
- const source = new LiteralSource ( {
1092
- $substitute : { $name : 'FOO' , $parseFloat : true } ,
1093
- } ) ;
1094
-
1095
- await expect ( source . read ( [ substituteDirective ( ) ] ) ) . rejects . toThrow ( ) ;
1096
- } ) ;
1097
-
1098
- it ( 'parses boolean = true' , async ( ) => {
1099
- process . env . FOO = 'true' ;
1100
-
1101
- const source = new LiteralSource ( {
1102
- $substitute : { $name : 'FOO' , $parseBool : true } ,
1103
- } ) ;
1104
-
1105
- expect ( await source . readToJSON ( [ substituteDirective ( ) ] ) ) . toEqual ( true ) ;
1106
- } ) ;
1107
-
1108
- it ( 'parses boolean = 1' , async ( ) => {
1109
- process . env . FOO = '1' ;
1110
-
1111
- const source = new LiteralSource ( {
1112
- $substitute : { $name : 'FOO' , $parseBool : true } ,
1113
- } ) ;
1114
-
1115
- expect ( await source . readToJSON ( [ substituteDirective ( ) ] ) ) . toEqual ( true ) ;
1116
- } ) ;
1117
-
1118
- it ( 'parses boolean = 0' , async ( ) => {
1119
- process . env . FOO = '0' ;
1120
-
1121
- const source = new LiteralSource ( {
1122
- $substitute : { $name : 'FOO' , $parseBool : true } ,
1123
- } ) ;
1124
-
1125
- expect ( await source . readToJSON ( [ substituteDirective ( ) ] ) ) . toEqual ( false ) ;
1126
- } ) ;
1127
-
1128
- it ( 'parses boolean = false' , async ( ) => {
1129
- process . env . FOO = 'false' ;
1130
-
1131
- const source = new LiteralSource ( {
1132
- $substitute : { $name : 'FOO' , $parseBool : true } ,
1133
- } ) ;
1134
-
1135
- expect ( await source . readToJSON ( [ substituteDirective ( ) ] ) ) . toEqual ( false ) ;
1136
- } ) ;
1137
-
1138
- it ( 'doesnt visit fallback if name is defined' , async ( ) => {
1139
- const failDirective = forKey ( '$fail' , ( ) => ( ) => {
1140
- throw new Error ( ) ;
1141
- } ) ;
1142
-
1143
- process . env . FOO = 'foo' ;
1144
-
1145
- const source = new LiteralSource ( {
1146
- foo : { $substitute : { $name : 'FOO' , $fallback : { $fail : true } } } ,
1147
- } ) ;
1148
-
1149
- const parsed = await source . read ( [ substituteDirective ( ) , failDirective ] ) ;
1150
-
1151
- expect ( parsed . toJSON ( ) ) . toEqual ( { foo : 'foo' } ) ;
1152
- } ) ;
1153
-
1154
998
it ( 'reads object with name' , async ( ) => {
1155
999
process . env . FOO = 'foo' ;
1156
1000
@@ -1328,7 +1172,7 @@ describe('$envVar directive', () => {
1328
1172
expect ( parsed . toJSON ( ) ) . toEqual ( { foo : 'foo' , bar : 'bar' } ) ;
1329
1173
} ) ;
1330
1174
1331
- it ( 'reads object with $ name' , async ( ) => {
1175
+ it ( 'reads object with name' , async ( ) => {
1332
1176
process . env . FOO = 'foo' ;
1333
1177
1334
1178
const source = new LiteralSource ( {
@@ -1340,15 +1184,15 @@ describe('$envVar directive', () => {
1340
1184
expect ( parsed . toJSON ( ) ) . toEqual ( { foo : 'foo' } ) ;
1341
1185
} ) ;
1342
1186
1343
- it ( 'fails with $ name when not defined' , async ( ) => {
1187
+ it ( 'fails with name when not defined' , async ( ) => {
1344
1188
const source = new LiteralSource ( {
1345
1189
foo : { $envVar : { name : 'FOO' } } ,
1346
1190
} ) ;
1347
1191
1348
1192
await expect ( source . read ( [ envVarDirective ( ) ] ) ) . rejects . toThrow ( ) ;
1349
1193
} ) ;
1350
1194
1351
- it ( 'uses $ name when $ fallback is defined' , async ( ) => {
1195
+ it ( 'uses name when fallback is defined' , async ( ) => {
1352
1196
process . env . FOO = 'foo' ;
1353
1197
1354
1198
const source = new LiteralSource ( {
@@ -1360,7 +1204,7 @@ describe('$envVar directive', () => {
1360
1204
expect ( parsed . toJSON ( ) ) . toEqual ( { foo : 'foo' } ) ;
1361
1205
} ) ;
1362
1206
1363
- it ( 'uses $ fallback when $ name was not found' , async ( ) => {
1207
+ it ( 'uses fallback when name was not found' , async ( ) => {
1364
1208
const source = new LiteralSource ( {
1365
1209
foo : { $envVar : { name : 'FOO' , fallback : 'bar' } } ,
1366
1210
} ) ;
@@ -1370,7 +1214,7 @@ describe('$envVar directive', () => {
1370
1214
expect ( parsed . toJSON ( ) ) . toEqual ( { foo : 'bar' } ) ;
1371
1215
} ) ;
1372
1216
1373
- it ( 'allows null value when $ allowNull' , async ( ) => {
1217
+ it ( 'allows null value when allowNull' , async ( ) => {
1374
1218
const source = new LiteralSource ( {
1375
1219
foo : { $envVar : { name : 'FOO' , fallback : null , allowNull : true } } ,
1376
1220
} ) ;
@@ -1380,7 +1224,7 @@ describe('$envVar directive', () => {
1380
1224
expect ( parsed . toJSON ( ) ) . toEqual ( { foo : null } ) ;
1381
1225
} ) ;
1382
1226
1383
- it ( 'does not allow number even when $ allowNull' , async ( ) => {
1227
+ it ( 'does not allow number even when allowNull' , async ( ) => {
1384
1228
const source = new LiteralSource ( {
1385
1229
foo : { $envVar : { name : 'FOO' , fallback : 42 , allowNull : true } } ,
1386
1230
} ) ;
0 commit comments