|
7 | 7 | CustomDomainsManager, |
8 | 8 | PostCustomDomainsRequestTypeEnum, |
9 | 9 | ManagementClient, |
| 10 | + ApiResponse, |
| 11 | + GetCustomDomains200Response, |
10 | 12 | } from '../../src/index.js'; |
11 | 13 |
|
12 | 14 | describe('CustomDomainsManager', () => { |
@@ -49,7 +51,7 @@ describe('CustomDomainsManager', () => { |
49 | 51 |
|
50 | 52 | describe('#getAll', () => { |
51 | 53 | let request: nock.Scope; |
52 | | - const response: CustomDomain[] = [ |
| 54 | + const response: Array<CustomDomain> = [ |
53 | 55 | { |
54 | 56 | custom_domain_id: 'test_domain', |
55 | 57 | domain: 'Test Domain', |
@@ -91,29 +93,29 @@ describe('CustomDomainsManager', () => { |
91 | 93 | }); |
92 | 94 |
|
93 | 95 | it('should pass the body of the response to the "then" handler', (done) => { |
94 | | - customDomains.getAll().then((customDomains) => { |
| 96 | + customDomains.getAll().then((customDomains: ApiResponse<GetCustomDomains200Response>) => { |
95 | 97 | expect(customDomains.data).toBeInstanceOf(Array); |
96 | | - expect(customDomains.data.length).toBe(response.length); |
97 | | - |
98 | | - expect(customDomains.data[0].custom_domain_id).toBe(response[0].custom_domain_id); |
99 | | - expect(customDomains.data[0].domain).toBe(response[0].domain); |
100 | | - expect(customDomains.data[0].primary).toBe(response[0].primary); |
101 | | - expect(customDomains.data[0].status).toBe(response[0].status); |
102 | | - expect(customDomains.data[0].type).toBe(response[0].type); |
103 | | - expect(customDomains.data[0].origin_domain_name).toBe(response[0].origin_domain_name); |
104 | | - expect(customDomains.data[0].verification?.methods?.[0].name).toBe( |
| 98 | + expect((customDomains.data as Array<CustomDomain>).length).toBe(response.length); |
| 99 | + |
| 100 | + const customDomainData: CustomDomain = (customDomains.data as Array<CustomDomain>)[0]; |
| 101 | + |
| 102 | + expect(customDomainData.custom_domain_id).toBe(response[0].custom_domain_id); |
| 103 | + expect(customDomainData.domain).toBe(response[0].domain); |
| 104 | + expect(customDomainData.primary).toBe(response[0].primary); |
| 105 | + expect(customDomainData.status).toBe(response[0].status); |
| 106 | + expect(customDomainData.type).toBe(response[0].type); |
| 107 | + expect(customDomainData.origin_domain_name).toBe(response[0].origin_domain_name); |
| 108 | + expect(customDomainData.verification?.methods?.[0].name).toBe( |
105 | 109 | response[0].verification?.methods?.[0].name |
106 | 110 | ); |
107 | | - expect(customDomains.data[0].verification?.methods?.[0].record).toBe( |
| 111 | + expect(customDomainData.verification?.methods?.[0].record).toBe( |
108 | 112 | response[0].verification?.methods?.[0].record |
109 | 113 | ); |
110 | | - expect(customDomains.data[0].verification?.methods?.[0].domain).toBe( |
| 114 | + expect(customDomainData.verification?.methods?.[0].domain).toBe( |
111 | 115 | response[0].verification?.methods?.[0].domain |
112 | 116 | ); |
113 | | - expect(customDomains.data[0].custom_client_ip_header).toBe( |
114 | | - response[0].custom_client_ip_header |
115 | | - ); |
116 | | - expect(customDomains.data[0].tls_policy).toBe(response[0].tls_policy); |
| 117 | + expect(customDomainData.custom_client_ip_header).toBe(response[0].custom_client_ip_header); |
| 118 | + expect(customDomainData.tls_policy).toBe(response[0].tls_policy); |
117 | 119 |
|
118 | 120 | done(); |
119 | 121 | }); |
|
0 commit comments