@@ -27,12 +27,13 @@ describe('Feature Flag Client', () => {
2727
2828 it ( 'should list feature flags' , async ( ) => {
2929 const appConfigEndpoint = 'https://example.com'
30+ const label = 'test-label'
3031 const getMock = jest . spyOn ( axios , 'get' ) . mockResolvedValue ( {
3132 status : 200 ,
3233 data : featureListResponse
3334 } )
3435
35- const results = await listFeatureFlags ( appConfigEndpoint )
36+ const results = await listFeatureFlags ( appConfigEndpoint , label )
3637 expect ( results . items . length ) . toEqual ( 1 )
3738 expect ( results . items [ 0 ] . key ) . toEqual (
3839 '.appconfig.featureflag/featureFlagId1'
@@ -41,27 +42,36 @@ describe('Feature Flag Client', () => {
4142
4243 it ( 'should throw error when list api fails' , async ( ) => {
4344 const appConfigEndpoint = 'https://example.com'
45+ const label = 'test-label'
4446
4547 const getMock = jest . spyOn ( axios , 'get' ) . mockResolvedValue ( {
4648 status : 500 ,
4749 statusText : 'Internal Server Error'
4850 } )
4951
50- await expect ( listFeatureFlags ( appConfigEndpoint ) ) . rejects . toThrow ( ApiError )
52+ await expect ( listFeatureFlags ( appConfigEndpoint , label ) ) . rejects . toThrow (
53+ ApiError
54+ )
5155 } )
5256
5357 it ( 'create or update feature flag' , async ( ) => {
5458 const appConfigEndpoint = 'https://example.com'
5559 const featureFlagId = 'featureFlagId1'
60+ const label = 'test-label'
5661 const value = getDummyFeatureFlagItem ( featureFlagId )
5762
5863 const getMock = jest . spyOn ( axios , 'put' ) . mockResolvedValue ( {
5964 status : 200
6065 } )
6166
62- await createOrUpdateFeatureFlag ( appConfigEndpoint , featureFlagId , value )
67+ await createOrUpdateFeatureFlag (
68+ appConfigEndpoint ,
69+ featureFlagId ,
70+ value ,
71+ label
72+ )
6373 expect ( getMock ) . toBeCalledWith (
64- `${ appConfigEndpoint } /kv/.appconfig.featureflag%2FfeatureFlagId1?api-version=2023-11-01` ,
74+ `${ appConfigEndpoint } /kv/.appconfig.featureflag%2FfeatureFlagId1?api-version=2023-11-01&label=test-label ` ,
6575 {
6676 content_type :
6777 'application/vnd.microsoft.appconfig.ff+json;charset=utf-8' ,
@@ -80,6 +90,7 @@ describe('Feature Flag Client', () => {
8090 it ( 'should throw error when create or update feature flag fails' , async ( ) => {
8191 const appConfigEndpoint = 'https://example.com'
8292 const featureFlagId = 'featureFlagId1'
93+ const label = 'test-label'
8394 const value = getDummyFeatureFlagItem ( featureFlagId )
8495
8596 const getMock = jest . spyOn ( axios , 'put' ) . mockResolvedValue ( {
@@ -88,21 +99,22 @@ describe('Feature Flag Client', () => {
8899 } )
89100
90101 await expect (
91- createOrUpdateFeatureFlag ( appConfigEndpoint , featureFlagId , value )
102+ createOrUpdateFeatureFlag ( appConfigEndpoint , featureFlagId , value , label )
92103 ) . rejects . toThrow ( ApiError )
93104 } )
94105
95106 it ( 'should delete feature flag' , async ( ) => {
96107 const appConfigEndpoint = 'https://example.com'
97108 const featureFlagId = 'featureFlagId1'
109+ const label = 'test-label'
98110
99111 const getMock = jest . spyOn ( axios , 'delete' ) . mockResolvedValue ( {
100112 status : 200
101113 } )
102114
103- await deleteFeatureFlag ( appConfigEndpoint , featureFlagId )
115+ await deleteFeatureFlag ( appConfigEndpoint , featureFlagId , label )
104116 expect ( getMock ) . toBeCalledWith (
105- `${ appConfigEndpoint } /kv/.appconfig.featureflag%2FfeatureFlagId1?api-version=2023-11-01` ,
117+ `${ appConfigEndpoint } /kv/.appconfig.featureflag%2FfeatureFlagId1?api-version=2023-11-01&label=test-label ` ,
106118 {
107119 headers : {
108120 Accept : '*/*' ,
@@ -116,13 +128,14 @@ describe('Feature Flag Client', () => {
116128 it ( 'should throw error when delete feature flag fails' , async ( ) => {
117129 const appConfigEndpoint = 'https://example.com'
118130 const featureFlagId = 'featureFlagId1'
131+ const label = 'test-label'
119132
120133 const getMock = jest . spyOn ( axios , 'delete' ) . mockResolvedValue ( {
121134 status : 500
122135 } )
123136
124137 await expect (
125- deleteFeatureFlag ( appConfigEndpoint , featureFlagId )
138+ deleteFeatureFlag ( appConfigEndpoint , featureFlagId , label )
126139 ) . rejects . toThrow ( ApiError )
127140 } )
128141
0 commit comments