@@ -3,111 +3,51 @@ import { describe, it } from 'vitest';
3
3
import enforceProxyConfigurationType from './enforce-proxy-configuration-type' ;
4
4
5
5
const ruleTester = new RuleTester ( {
6
- parser : require . resolve ( '@typescript-eslint/parser' ) ,
7
- parserOptions : {
8
- ecmaVersion : 2018 ,
9
- sourceType : 'module' ,
10
- } ,
6
+ parser : require . resolve ( '@typescript-eslint/parser' ) ,
7
+ parserOptions : { ecmaVersion : 2018 , sourceType : 'module' } ,
11
8
} ) ;
12
9
13
- describe ( 'enforce-proxy-configuration-type' , ( ) => {
14
- it ( 'should pass valid cases and fail invalid cases' , ( ) => {
15
- ruleTester . run ( 'enforce-proxy-configuration-type' , enforceProxyConfigurationType , {
16
- valid : [
17
- {
18
- code : `
19
- const config: ProxyConfiguration = {
20
- endpoint: 'api.xro/2.0/Contacts',
21
- headers: { 'xero-tenant-id': tenant_id },
22
- params: { summarizeErrors: 'false' },
23
- data: { Contacts: input.map(toXeroContact) }
24
- };
25
- const res = await nango.post(config);
26
- ` ,
27
- } ,
28
- {
29
- code : `
30
- let config: ProxyConfiguration;
31
- config = {
32
- endpoint: 'api.xro/2.0/Contacts',
33
- headers: { 'xero-tenant-id': tenant_id },
34
- params: { summarizeErrors: 'false' },
35
- data: { Contacts: input.map(toXeroContact) }
36
- };
37
- const res = await nango.get(config);
38
- ` ,
39
- } ,
40
- {
41
- code : `
42
- const res = await nango.put({ endpoint: 'api.example.com', data: {} });
43
- ` ,
44
- } ,
45
- ] ,
46
- invalid : [
47
- {
48
- code : `
49
- const config = {
50
- endpoint: 'api.xro/2.0/Contacts',
51
- headers: { 'xero-tenant-id': tenant_id },
52
- params: { summarizeErrors: 'false' },
53
- data: { Contacts: input.map(toXeroContact) }
54
- };
55
- const res = await nango.post(config);
56
- ` ,
57
- errors : [ { message : 'Configuration object for Nango API calls should be typed as ProxyConfiguration' } ] ,
58
- output : `
59
- const config: ProxyConfiguration = {
60
- endpoint: 'api.xro/2.0/Contacts',
61
- headers: { 'xero-tenant-id': tenant_id },
62
- params: { summarizeErrors: 'false' },
63
- data: { Contacts: input.map(toXeroContact) }
64
- };
65
- const res = await nango.post(config);
66
- ` ,
67
- } ,
68
- {
69
- code : `
70
- let config = {
71
- endpoint: 'api.xro/2.0/Contacts',
72
- headers: { 'xero-tenant-id': tenant_id },
73
- params: { summarizeErrors: 'false' },
74
- data: { Contacts: input.map(toXeroContact) }
75
- };
76
- const res = await nango.get(config);
77
- ` ,
78
- errors : [ { message : 'Configuration object for Nango API calls should be typed as ProxyConfiguration' } ] ,
79
- output : `
80
- let config: ProxyConfiguration = {
81
- endpoint: 'api.xro/2.0/Contacts',
82
- headers: { 'xero-tenant-id': tenant_id },
83
- params: { summarizeErrors: 'false' },
84
- data: { Contacts: input.map(toXeroContact) }
85
- };
86
- const res = await nango.get(config);
87
- ` ,
88
- } ,
89
- {
90
- code : `
91
- var config = {
92
- endpoint: 'api.xro/2.0/Contacts',
93
- headers: { 'xero-tenant-id': tenant_id },
94
- params: { summarizeErrors: 'false' },
95
- data: { Contacts: input.map(toXeroContact) }
96
- };
97
- const res = await nango.proxy(config);
98
- ` ,
99
- errors : [ { message : 'Configuration object for Nango API calls should be typed as ProxyConfiguration' } ] ,
100
- output : `
101
- var config: ProxyConfiguration = {
102
- endpoint: 'api.xro/2.0/Contacts',
103
- headers: { 'xero-tenant-id': tenant_id },
104
- params: { summarizeErrors: 'false' },
105
- data: { Contacts: input.map(toXeroContact) }
106
- };
107
- const res = await nango.proxy(config);
108
- ` ,
109
- } ,
110
- ] ,
10
+ describe ( 'enforce-proxy-configuration-type-tests' , ( ) => {
11
+ it ( 'should pass valid cases and fail invalid cases' , ( ) => {
12
+ ruleTester . run ( 'enforce-proxy-configuration-type' , enforceProxyConfigurationType , {
13
+ valid : [
14
+ {
15
+ code : `
16
+ import type { NangoSync, Account, ProxyConfiguration } from '../../models';
17
+ const config: ProxyConfiguration = {
18
+ endpoint: 'api.xro/2.0/Accounts',
19
+ headers: { 'xero-tenant-id': tenant_id },
20
+ params: { order: 'UpdatedDateUTC DESC' },
21
+ retries: 10
22
+ };
23
+ ` ,
24
+ } ,
25
+ ] ,
26
+ invalid : [
27
+ {
28
+ code : `
29
+ import type { NangoSync, Account } from '../../models';
30
+ const config = {
31
+ endpoint: 'api.xro/2.0/Accounts',
32
+ headers: { 'xero-tenant-id': tenant_id },
33
+ params: { order: 'UpdatedDateUTC DESC' },
34
+ retries: 10
35
+ };
36
+ ` ,
37
+ errors : [
38
+ { message : 'ProxyConfiguration type should be imported and used for Nango API call configurations' } ,
39
+ ] ,
40
+ output : `
41
+ import type { NangoSync, Account, ProxyConfiguration } from '../../models';
42
+ const config: ProxyConfiguration = {
43
+ endpoint: 'api.xro/2.0/Accounts',
44
+ headers: { 'xero-tenant-id': tenant_id },
45
+ params: { order: 'UpdatedDateUTC DESC' },
46
+ retries: 10
47
+ };
48
+ ` ,
49
+ } ,
50
+ ] ,
51
+ } ) ;
111
52
} ) ;
112
- } ) ;
113
53
} ) ;
0 commit comments