@@ -87,10 +87,67 @@ class ContentstackConfigTest: XCTestCase {
87
87
let stack = makeStackSut ( config: config)
88
88
XCTAssertEqual ( stack. jsonDecoder. userInfo [ . timeZoneContextKey] as? TimeZone , timeZone)
89
89
}
90
+ func testEarlyAccessMultipleValues( ) {
91
+ var config = ContentstackConfig ( )
92
+ let earlyAccess : [ String ] = [ " Taxonomy " , " Teams " ]
93
+ config. setEarlyAccess ( earlyAccess)
94
+ _ = makeStackSut ( config: config)
95
+ let headers = config. getHeaders ( )
96
+ XCTAssertTrue ( headers. keys. contains ( " x-header-ea " ) )
97
+ XCTAssertEqual ( headers [ " x-header-ea " ] , " Taxonomy,Teams " )
98
+ }
99
+
100
+ func testDefaultEarlyAccessIsNil( ) {
101
+ var config = ContentstackConfig ( )
102
+ config. setEarlyAccess ( [ ] )
103
+ _ = makeStackSut ( config: config)
104
+ let headers = config. getHeaders ( )
105
+ print ( " headers:: " , headers)
106
+ XCTAssertFalse ( headers. keys. contains ( " x-header-ea " ) , " The headers should not contain the 'x-header-ea' key when early access is not set. " )
107
+ }
108
+
109
+ func testEarlyAccessSingleValue( ) {
110
+ var config = ContentstackConfig ( )
111
+ let earlyAccessFeatures = [ " feature1 " ]
112
+ config. setEarlyAccess ( earlyAccessFeatures)
113
+ _ = makeStackSut ( config: config)
114
+ let headers = config. getHeaders ( )
115
+ XCTAssertTrue ( headers. keys. contains ( " x-header-ea " ) , " The headers should contain the 'x-header-ea' key. " )
116
+ XCTAssertEqual ( headers [ " x-header-ea " ] , " feature1 " , " The 'x-header-ea' value should match the single early access value passed. " )
117
+ }
118
+
119
+ func testGetHeadersWithoutEarlyAccess( ) {
120
+ let config = ContentstackConfig ( )
121
+ let headers = config. getHeaders ( )
122
+ XCTAssertFalse ( headers. keys. contains ( " x-header-ea " ) )
123
+ }
124
+
125
+ func testMultipleEarlyAccessWithSpaces( ) {
126
+ var config = ContentstackConfig ( )
127
+ let earlyAccess : [ String ] = [ " Feature One " , " Feature Two " ]
128
+ config. setEarlyAccess ( earlyAccess)
129
+ _ = makeStackSut ( config: config)
130
+ let headers = config. getHeaders ( )
131
+ XCTAssertTrue ( headers. keys. contains ( " x-header-ea " ) , " The headers should contain the 'x-header-ea' key. " )
132
+ XCTAssertEqual ( headers [ " x-header-ea " ] , " Feature One,Feature Two " , " The 'x-header-ea' value should match the early access values with spaces. " )
133
+ }
134
+
135
+ func testDefaultConfigHasNoEarlyAccessHeaders( ) {
136
+ let config = ContentstackConfig ( )
137
+ _ = makeStackSut ( config: config)
138
+ let headers = config. getHeaders ( )
139
+ XCTAssertFalse ( headers. keys. contains ( " x-header-ea " ) , " The default config should not contain the 'x-header-ea' key. " )
140
+ }
90
141
91
142
static var allTests = [
92
143
( " testUserAgent " , testUserAgent) ,
93
144
( " testXUserAgent " , testXUserAgent) ,
94
- ( " testTimeZone_changetoCurrent " , testTimeZone_changetoCurrent)
145
+ ( " testTimeZone_changetoCurrent " , testTimeZone_changetoCurrent) ,
146
+ ( " testEarlyAccessMultipleValues " , testEarlyAccessMultipleValues) ,
147
+ ( " testDefaultEarlyAccessIsNil " , testDefaultEarlyAccessIsNil) ,
148
+ ( " testEarlyAccessSingleValue " , testEarlyAccessSingleValue) ,
149
+ ( " testGetHeadersWithoutEarlyAccess " , testGetHeadersWithoutEarlyAccess) ,
150
+ ( " testMultipleEarlyAccessWithSpaces " , testMultipleEarlyAccessWithSpaces) ,
151
+ ( " testDefaultConfigHasNoEarlyAccessHeaders " , testDefaultConfigHasNoEarlyAccessHeaders) ,
95
152
]
96
153
}
0 commit comments