|
| 1 | +import { arnPrefix, consoleDomain, dnsSuffix, getPartition, serviceEndpoint } from '../partition'; |
| 2 | +import { describe, expect, it } from 'vitest'; |
| 3 | + |
| 4 | +describe('getPartition', () => { |
| 5 | + it('returns aws for standard commercial regions', () => { |
| 6 | + expect(getPartition('us-east-1')).toBe('aws'); |
| 7 | + expect(getPartition('eu-west-1')).toBe('aws'); |
| 8 | + expect(getPartition('ap-southeast-1')).toBe('aws'); |
| 9 | + }); |
| 10 | + |
| 11 | + it('returns aws-us-gov for GovCloud regions', () => { |
| 12 | + expect(getPartition('us-gov-west-1')).toBe('aws-us-gov'); |
| 13 | + expect(getPartition('us-gov-east-1')).toBe('aws-us-gov'); |
| 14 | + }); |
| 15 | + |
| 16 | + it('returns aws-cn for China regions', () => { |
| 17 | + expect(getPartition('cn-north-1')).toBe('aws-cn'); |
| 18 | + expect(getPartition('cn-northwest-1')).toBe('aws-cn'); |
| 19 | + }); |
| 20 | +}); |
| 21 | + |
| 22 | +describe('arnPrefix', () => { |
| 23 | + it('returns arn:aws for commercial regions', () => { |
| 24 | + expect(arnPrefix('us-east-1')).toBe('arn:aws'); |
| 25 | + }); |
| 26 | + |
| 27 | + it('returns arn:aws-us-gov for GovCloud regions', () => { |
| 28 | + expect(arnPrefix('us-gov-west-1')).toBe('arn:aws-us-gov'); |
| 29 | + }); |
| 30 | + |
| 31 | + it('returns arn:aws-cn for China regions', () => { |
| 32 | + expect(arnPrefix('cn-north-1')).toBe('arn:aws-cn'); |
| 33 | + }); |
| 34 | +}); |
| 35 | + |
| 36 | +describe('dnsSuffix', () => { |
| 37 | + it('returns amazonaws.com for commercial regions', () => { |
| 38 | + expect(dnsSuffix('us-east-1')).toBe('amazonaws.com'); |
| 39 | + }); |
| 40 | + |
| 41 | + it('returns amazonaws.com for GovCloud regions', () => { |
| 42 | + expect(dnsSuffix('us-gov-west-1')).toBe('amazonaws.com'); |
| 43 | + }); |
| 44 | + |
| 45 | + it('returns amazonaws.com.cn for China regions', () => { |
| 46 | + expect(dnsSuffix('cn-north-1')).toBe('amazonaws.com.cn'); |
| 47 | + }); |
| 48 | +}); |
| 49 | + |
| 50 | +describe('serviceEndpoint', () => { |
| 51 | + it('builds correct endpoint for commercial regions', () => { |
| 52 | + expect(serviceEndpoint('bedrock-agentcore', 'us-east-1')).toBe('bedrock-agentcore.us-east-1.amazonaws.com'); |
| 53 | + }); |
| 54 | + |
| 55 | + it('builds correct endpoint for GovCloud regions', () => { |
| 56 | + expect(serviceEndpoint('bedrock-agentcore', 'us-gov-west-1')).toBe('bedrock-agentcore.us-gov-west-1.amazonaws.com'); |
| 57 | + }); |
| 58 | + |
| 59 | + it('builds correct endpoint for China regions', () => { |
| 60 | + expect(serviceEndpoint('bedrock-agentcore', 'cn-north-1')).toBe('bedrock-agentcore.cn-north-1.amazonaws.com.cn'); |
| 61 | + }); |
| 62 | +}); |
| 63 | + |
| 64 | +describe('consoleDomain', () => { |
| 65 | + it('returns console.aws.amazon.com for commercial regions', () => { |
| 66 | + expect(consoleDomain('us-east-1')).toBe('console.aws.amazon.com'); |
| 67 | + }); |
| 68 | + |
| 69 | + it('returns console.amazonaws-us-gov.com for GovCloud regions', () => { |
| 70 | + expect(consoleDomain('us-gov-west-1')).toBe('console.amazonaws-us-gov.com'); |
| 71 | + }); |
| 72 | + |
| 73 | + it('returns console.amazonaws.cn for China regions', () => { |
| 74 | + expect(consoleDomain('cn-north-1')).toBe('console.amazonaws.cn'); |
| 75 | + }); |
| 76 | +}); |
0 commit comments