@@ -119,6 +119,61 @@ - (void)tearDown {
119119#pragma mark Test Case - Header
120120
121121
122+ - (void )testStackHeadersEarlyAccess {
123+ XCTestExpectation *expectation = [self expectationWithDescription: @" EarlyAccessHeadersPassed" ];
124+ config = [[Config alloc ] init ];
125+ config.setEarlyAccess = @[@" Taxonomy" , @" Teams" , @" Terms" , @" LivePreview" ];
126+ csStack = [Contentstack stackWithAPIKey: @" apikey" accessToken: @" delivery_token" environmentName: @" environment" config: config];
127+ // Check the headers in the stack
128+ NSDictionary *headers = [csStack getHeaders ];
129+ // Check if the early access headers are set correctly
130+ NSString *expectedHeaderValue = @" Taxonomy,Teams,Terms,LivePreview" ;
131+ NSString *earlyAccessHeader = headers[@" x-header-ea" ];
132+
133+ XCTAssertNotNil (earlyAccessHeader, @" Early access header should be present" );
134+ XCTAssertEqualObjects (earlyAccessHeader, expectedHeaderValue, @" Early access header should match the expected value" );
135+
136+ // Fulfill the expectation to mark the test as completed
137+ [expectation fulfill ];
138+
139+ // Wait for the request to complete
140+ [self waitForExpectationsWithTimeout: kRequestTimeOutInSeconds handler: ^(NSError *error) {
141+ if (error) {
142+ XCTFail (@" Test timed out: %@ " , error.localizedDescription );
143+ }
144+ }];
145+ }
146+
147+ - (void )testNoEarlyAccessHeaders {
148+ XCTestExpectation *expectation = [self expectationWithDescription: @" NoEarlyAccessHeaders" ];
149+ config = [[Config alloc ] init ];
150+ csStack = [Contentstack stackWithAPIKey: @" apikey" accessToken: @" delivery_token" environmentName: @" environment" config: config];
151+
152+ NSDictionary *headers = [csStack getHeaders ];
153+ NSString *earlyAccessHeader = headers[@" x-header-ea" ];
154+ XCTAssertNil (earlyAccessHeader, @" Early access header should not be present when no early access features are set" );
155+
156+ [expectation fulfill ];
157+ [self waitForExpectationsWithTimeout: kRequestTimeOutInSeconds handler: nil ];
158+ }
159+
160+ - (void )testSingleEarlyAccessHeader {
161+ XCTestExpectation *expectation = [self expectationWithDescription: @" SingleEarlyAccessHeader" ];
162+ config = [[Config alloc ] init ];
163+ config.setEarlyAccess = @[@" LivePreview" ];
164+ csStack = [Contentstack stackWithAPIKey: @" apikey" accessToken: @" delivery_token" environmentName: @" environment" config: config];
165+
166+ NSDictionary *headers = [csStack getHeaders ];
167+ NSString *expectedHeaderValue = @" LivePreview" ;
168+ NSString *earlyAccessHeader = headers[@" x-header-ea" ];
169+ XCTAssertNotNil (earlyAccessHeader, @" Early access header should be present" );
170+ XCTAssertEqualObjects (earlyAccessHeader, expectedHeaderValue, @" Single early access header should match the expected value" );
171+
172+ [expectation fulfill ];
173+ [self waitForExpectationsWithTimeout: kRequestTimeOutInSeconds handler: nil ];
174+ }
175+
176+
122177- (void )test01FetchSourceEntries {
123178 XCTestExpectation *expectation = [self expectationWithDescription: @" Fetch All Entries" ];
124179
0 commit comments