Skip to content

Commit 6c1def0

Browse files
feat: added gcp_na region
1 parent 90c8297 commit 6c1def0

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export enum Region {
2323
US = "us",
2424
EU = "eu",
2525
AZURE_NA = "azure-na",
26-
AZURE_EU = "azure-eu"
26+
AZURE_EU = "azure-eu",
27+
GCP_NA = "gcp-na",
2728
}
2829

2930
//Enum for Contentstack CachePolicy

src/core/contentstackregion.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const ContentstackRegion = {
22
EU: "eu",
33
US: "us",
44
AZURE_NA: "azure-na",
5-
AZURE_EU: "azure-eu"
5+
AZURE_EU: "azure-eu",
6+
GCP_NA: "gcp-na",
67
};
78

8-
export default ContentstackRegion;
9-
//module.exports = ContentstackRegion;
9+
export default ContentstackRegion;

test/typescript/stack.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,34 @@ describe('Stack tests', () => {
167167
expect(stack.fetchOptions.retryDelay).toEqual(40);
168168
done();
169169
});
170+
171+
test('Stack initialization with Contentstack Config with fetchOptions, GCP-NA region test', done => {
172+
const config : Contentstack.Config = {
173+
api_key: 'api_key',
174+
delivery_token: 'delivery_token',
175+
environment: 'environment',
176+
region: Contentstack.Region.GCP_NA,
177+
fetchOptions:{
178+
timeout: 2000,
179+
retryLimit: 4,
180+
retryDelay: 40,
181+
logHandler: () => {
182+
183+
}
184+
}
185+
};
186+
const stack = Contentstack.Stack(config);
187+
188+
expect(stack.cachePolicy).toEqual(Contentstack.CachePolicy.IGNORE_CACHE);
189+
expect(stack.environment).toEqual('environment');
190+
expect(stack.config.host).toEqual('gcp-na-cdn.contentstack.com');
191+
expect(stack.config.port).toEqual(443);
192+
expect(stack.config.version).toEqual("v3");
193+
expect(stack.fetchOptions.timeout).toEqual(2000);
194+
expect(stack.fetchOptions.retryLimit).toEqual(4);
195+
expect(stack.fetchOptions.retryDelay).toEqual(40);
196+
done();
197+
});
170198

171199
test('Stack initialization with region EU test', done => {
172200
const stack = Contentstack.Stack('api_key', 'delivery_token', 'environment', Contentstack.Region.AZURE_NA);

0 commit comments

Comments
 (0)