@@ -13,24 +13,25 @@ import {AvailableFeature} from '../types'
1313
1414describe ( 'given a feature flags provider and a list of rules' , ( ) => {
1515 const subject = featureFlagsProvider
16+ let region : string | undefined = 'us-west-1'
1617
1718 describe ( 'when the features list is retrieved' , ( ) => {
1819 it ( 'should return the list' , async ( ) => {
19- const features = await subject ( '0.0.0' )
20+ const features = await subject ( '0.0.0' , region )
2021 expect ( features ) . toEqual < AvailableFeature [ ] > ( [ ] )
2122 } )
2223 } )
2324
2425 describe ( 'when the version is between 3.1.0 and 3.2.0' , ( ) => {
2526 it ( 'should return the list of available features' , async ( ) => {
26- const features = await subject ( '3.1.5' )
27+ const features = await subject ( '3.1.5' , region )
2728 expect ( features ) . toEqual < AvailableFeature [ ] > ( [ 'multiuser_cluster' ] )
2829 } )
2930 } )
3031
3132 describe ( 'when the version is between 3.2.0 and 3.3.0' , ( ) => {
3233 it ( 'should return the list of available features' , async ( ) => {
33- const features = await subject ( '3.2.5' )
34+ const features = await subject ( '3.2.5' , region )
3435 expect ( features ) . toEqual < AvailableFeature [ ] > ( [
3536 'multiuser_cluster' ,
3637 'fsx_ontap' ,
@@ -46,7 +47,7 @@ describe('given a feature flags provider and a list of rules', () => {
4647
4748 describe ( 'when the version is between 3.3.0 and 3.4.0' , ( ) => {
4849 it ( 'should return the list of available features' , async ( ) => {
49- const features = await subject ( '3.3.2' )
50+ const features = await subject ( '3.3.2' , region )
5051 expect ( features ) . toEqual < AvailableFeature [ ] > ( [
5152 'multiuser_cluster' ,
5253 'fsx_ontap' ,
@@ -68,7 +69,7 @@ describe('given a feature flags provider and a list of rules', () => {
6869
6970 describe ( 'when the version is between 3.4.0 and 3.6.0' , ( ) => {
7071 it ( 'should return the list of available features' , async ( ) => {
71- const features = await subject ( '3.4.1' )
72+ const features = await subject ( '3.4.1' , region )
7273 expect ( features ) . toEqual < AvailableFeature [ ] > ( [
7374 'multiuser_cluster' ,
7475 'fsx_ontap' ,
@@ -92,7 +93,7 @@ describe('given a feature flags provider and a list of rules', () => {
9293
9394 describe ( 'when the version is above and 3.6.0' , ( ) => {
9495 it ( 'should return the list of available features' , async ( ) => {
95- const features = await subject ( '3.6.0' )
96+ const features = await subject ( '3.6.0' , region )
9697 expect ( features ) . toEqual < AvailableFeature [ ] > ( [
9798 'multiuser_cluster' ,
9899 'fsx_ontap' ,
@@ -122,7 +123,7 @@ describe('given a feature flags provider and a list of rules', () => {
122123 window . sessionStorage . setItem ( 'additionalFeatures' , '["cost_monitoring"]' )
123124 } )
124125 it ( 'should be included in the list of features' , async ( ) => {
125- const features = await subject ( '3.1.5' )
126+ const features = await subject ( '3.1.5' , region )
126127 expect ( features ) . toEqual < AvailableFeature [ ] > ( [
127128 'multiuser_cluster' ,
128129 'cost_monitoring' ,
@@ -135,8 +136,24 @@ describe('given a feature flags provider and a list of rules', () => {
135136 window . sessionStorage . clear ( )
136137 } )
137138 it ( 'should not be included in the list of features' , async ( ) => {
138- const features = await subject ( '3.1.5' )
139+ const features = await subject ( '3.1.5' , region )
139140 expect ( features ) . toEqual < AvailableFeature [ ] > ( [ 'multiuser_cluster' ] )
140141 } )
141142 } )
143+
144+ describe ( 'when a feature is not supported in a region' , ( ) => {
145+ it ( 'should return the list of available features without the unsupported feature' , async ( ) => {
146+ region = 'us-gov-west-1'
147+ const features = await subject ( '3.6.0' , region )
148+ expect ( features ) . not . toContain < AvailableFeature [ ] > ( [ 'cost_monitoring' ] )
149+ } )
150+ } )
151+
152+ describe ( 'when a feature is not supported in a region and the region is undefined' , ( ) => {
153+ it ( 'should return an empty list' , async ( ) => {
154+ region = undefined
155+ const features = await subject ( '3.6.0' , region )
156+ expect ( features ) . not . toContain < AvailableFeature [ ] > ( [ 'cost_monitoring' ] )
157+ } )
158+ } )
142159} )
0 commit comments