@@ -6,7 +6,7 @@ import * as chaiAsPromised from "chai-as-promised";
6
6
chai . use ( chaiAsPromised ) ;
7
7
const expect = chai . expect ;
8
8
import { load } from "./exportedApi" ;
9
- import { mockAppConfigurationClientListConfigurationSettings , restoreMocks , createMockedConnectionString , createMockedEnpoint , createMockedTokenCredential , createMockedKeyValue } from "./utils/testHelper" ;
9
+ import { mockAppConfigurationClientListConfigurationSettings , restoreMocks , createMockedConnectionString , createMockedEndpoint , createMockedTokenCredential , createMockedKeyValue } from "./utils/testHelper" ;
10
10
11
11
const mockedKVs = [ {
12
12
key : "app.settings.fontColor" ,
@@ -62,6 +62,17 @@ const mockedKVs = [{
62
62
} , {
63
63
key : "app5.settings" ,
64
64
value : "placeholder"
65
+ } , {
66
+ key : ".appconfig.featureflag/Beta" ,
67
+ value : JSON . stringify ( {
68
+ "id" : "Beta" ,
69
+ "description" : "" ,
70
+ "enabled" : true ,
71
+ "conditions" : {
72
+ "client_filters" : [ ]
73
+ }
74
+ } ) ,
75
+ contentType : "application/vnd.microsoft.appconfig.ff+json;charset=utf-8"
65
76
}
66
77
] . map ( createMockedKeyValue ) ;
67
78
@@ -84,7 +95,7 @@ describe("load", function () {
84
95
} ) ;
85
96
86
97
it ( "should load data from config store with aad + endpoint URL" , async ( ) => {
87
- const endpoint = createMockedEnpoint ( ) ;
98
+ const endpoint = createMockedEndpoint ( ) ;
88
99
const credential = createMockedTokenCredential ( ) ;
89
100
const settings = await load ( new URL ( endpoint ) , credential ) ;
90
101
expect ( settings ) . not . undefined ;
@@ -93,7 +104,7 @@ describe("load", function () {
93
104
} ) ;
94
105
95
106
it ( "should load data from config store with aad + endpoint string" , async ( ) => {
96
- const endpoint = createMockedEnpoint ( ) ;
107
+ const endpoint = createMockedEndpoint ( ) ;
97
108
const credential = createMockedTokenCredential ( ) ;
98
109
const settings = await load ( endpoint , credential ) ;
99
110
expect ( settings ) . not . undefined ;
@@ -110,6 +121,13 @@ describe("load", function () {
110
121
return expect ( load ( "invalid-endpoint-url" , credential ) ) . eventually . rejectedWith ( "Invalid endpoint URL." ) ;
111
122
} ) ;
112
123
124
+ it ( "should not include feature flags directly in the settings" , async ( ) => {
125
+ const connectionString = createMockedConnectionString ( ) ;
126
+ const settings = await load ( connectionString ) ;
127
+ expect ( settings ) . not . undefined ;
128
+ expect ( settings . get ( ".appconfig.featureflag/Beta" ) ) . undefined ;
129
+ } ) ;
130
+
113
131
it ( "should filter by key and label, has(key) and get(key) should work" , async ( ) => {
114
132
const connectionString = createMockedConnectionString ( ) ;
115
133
const settings = await load ( connectionString , {
@@ -251,7 +269,7 @@ describe("load", function () {
251
269
expect ( settings . get ( "TestKey" ) ) . eq ( "TestValueForProd" ) ;
252
270
} ) ;
253
271
254
- it ( "should dedup exact same selectors but keeping the precedence" , async ( ) => {
272
+ it ( "should deduplicate exact same selectors but keeping the precedence" , async ( ) => {
255
273
const connectionString = createMockedConnectionString ( ) ;
256
274
const settings = await load ( connectionString , {
257
275
selectors : [ {
@@ -317,7 +335,7 @@ describe("load", function () {
317
335
* key: "app3.settings.fontColor" => value: "yellow"
318
336
*
319
337
* get() will return "placeholder" for "app3.settings" and "yellow" for "app3.settings.fontColor", as expected.
320
- * data.app3.settings will return "placeholder" as a whole JSON object, which is not guarenteed to be correct.
338
+ * data.app3.settings will return "placeholder" as a whole JSON object, which is not guaranteed to be correct.
321
339
*/
322
340
it ( "Edge case 1: Hierarchical key-value pairs with overlapped key prefix." , async ( ) => {
323
341
const connectionString = createMockedConnectionString ( ) ;
@@ -337,7 +355,7 @@ describe("load", function () {
337
355
* key: "app5.settings.fontColor" => value: "yellow"
338
356
* key: "app5.settings" => value: "placeholder"
339
357
*
340
- * When ocnstructConfigurationObject () is called, it first constructs from key "app5.settings.fontColor" and then from key "app5.settings".
358
+ * When constructConfigurationObject () is called, it first constructs from key "app5.settings.fontColor" and then from key "app5.settings".
341
359
* An error will be thrown when constructing from key "app5.settings" because there is ambiguity between the two keys.
342
360
*/
343
361
it ( "Edge case 1: Hierarchical key-value pairs with overlapped key prefix." , async ( ) => {
0 commit comments