Skip to content

Commit f45d9de

Browse files
committed
chore: format test codes
1 parent c0dc39b commit f45d9de

15 files changed

+105
-105
lines changed

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
CHANGELOG.md
2-
*.test.js

__tests__/apigw.test.js

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -106,53 +106,60 @@ describe('apigw', () => {
106106
subDomain: expect.stringContaining('.apigw.tencentcs.com'),
107107
protocols: inputs.protocols,
108108
environment: 'release',
109-
apiList: [{
110-
path: '/',
111-
bindType: 'API',
112-
internalDomain: null,
113-
method: 'GET',
114-
apiName: 'index',
115-
apiId: expect.stringContaining('api-'),
116-
created: true,
117-
usagePlan: {
109+
apiList: [
110+
{
111+
path: '/',
112+
bindType: 'API',
113+
internalDomain: null,
114+
method: 'GET',
115+
apiName: 'index',
116+
apiId: expect.stringContaining('api-'),
118117
created: true,
119-
secrets: {
120-
'created': false,
121-
'secretIds': [],
118+
usagePlan: {
119+
created: true,
120+
secrets: {
121+
created: false,
122+
secretIds: [],
123+
},
124+
usagePlanId: expect.stringContaining('usagePlan-'),
122125
},
123-
usagePlanId: expect.stringContaining('usagePlan-'),
124126
},
125-
},{
126-
path: '/mo',
127-
method: 'GET',
128-
apiName: 'mo',
129-
internalDomain: null,
130-
apiId: expect.stringContaining('api-'),
131-
created: true,
132-
},{
133-
path: '/auto',
134-
method: 'GET',
135-
apiName: 'auto-http',
136-
internalDomain: null,
137-
apiId: expect.stringContaining('api-'),
138-
created: true,
139-
},{
140-
path: '/ws',
141-
method: 'GET',
142-
apiName: 'ws-test',
143-
internalDomain: null,
144-
apiId: expect.stringContaining('api-'),
145-
created: true,
146-
},{
147-
path: '/wsf',
148-
method: 'GET',
149-
apiName: 'ws-scf',
150-
internalDomain: expect.stringContaining('http://set-websocket.cb-common.apigateway.tencentyun.com'),
151-
apiId: expect.stringContaining('api-'),
152-
created: true,
153-
}],
127+
{
128+
path: '/mo',
129+
method: 'GET',
130+
apiName: 'mo',
131+
internalDomain: null,
132+
apiId: expect.stringContaining('api-'),
133+
created: true,
134+
},
135+
{
136+
path: '/auto',
137+
method: 'GET',
138+
apiName: 'auto-http',
139+
internalDomain: null,
140+
apiId: expect.stringContaining('api-'),
141+
created: true,
142+
},
143+
{
144+
path: '/ws',
145+
method: 'GET',
146+
apiName: 'ws-test',
147+
internalDomain: null,
148+
apiId: expect.stringContaining('api-'),
149+
created: true,
150+
},
151+
{
152+
path: '/wsf',
153+
method: 'GET',
154+
apiName: 'ws-scf',
155+
internalDomain: expect.stringContaining(
156+
'http://set-websocket.cb-common.apigateway.tencentyun.com',
157+
),
158+
apiId: expect.stringContaining('api-'),
159+
created: true,
160+
},
161+
],
154162
});
155-
156163
});
157164

158165
test('should remove apigw success', async () => {
@@ -165,4 +172,3 @@ describe('apigw', () => {
165172
expect(detail).toBeNull();
166173
});
167174
});
168-

__tests__/cam.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,3 @@ describe('Cam', () => {
4242
expect(res).toBe(true);
4343
});
4444
});
45-

__tests__/cdn.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ describe('Cdn', () => {
1212
area: 'overseas',
1313
domain: process.env.SUB_DOMAIN,
1414
origin: {
15-
origins: [`${process.env.BUCKET}-${process.env.TENCENT_APP_ID}.cos.${process.env.REGION}.myqcloud.com`],
15+
origins: [
16+
`${process.env.BUCKET}-${process.env.TENCENT_APP_ID}.cos.${process.env.REGION}.myqcloud.com`,
17+
],
1618
originType: 'cos',
1719
originPullProtocol: 'https',
1820
},
@@ -44,7 +46,6 @@ describe('Cdn', () => {
4446
});
4547
});
4648

47-
4849
test('should deploy CDN success with originType = domain', async () => {
4950
inputs.origin.originType = 'domain';
5051
const res = await cdn.deploy(inputs);
@@ -65,4 +66,3 @@ describe('Cdn', () => {
6566
expect(detail).toBeUndefined();
6667
});
6768
});
68-

__tests__/cfs.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@ describe('Cfs', () => {
4141
expect(detail).toBeUndefined();
4242
});
4343
});
44-

__tests__/cns.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,3 @@ describe('Cns', () => {
7171
expect(res).toEqual(true);
7272
});
7373
});
74-

__tests__/cos.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('Cos', () => {
3434
],
3535
};
3636

37-
const websiteInputs = {
37+
const websiteInputs = {
3838
code: {
3939
src: staticPath,
4040
},
@@ -75,4 +75,3 @@ describe('Cos', () => {
7575
}
7676
});
7777
});
78-

__tests__/domain.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,4 @@ describe('Domain', () => {
1414
subDomain: expect.any(String),
1515
});
1616
});
17-
1817
});
19-
20-

__tests__/error.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ const { TypeError, ApiError } = require('../src/utils/error');
33
describe('Custom Error', () => {
44
test('TypeError', async () => {
55
try {
6-
throw new TypeError('TEST_TypeError', 'This is a test error', 'error stack', 123, 'error test');
6+
throw new TypeError(
7+
'TEST_TypeError',
8+
'This is a test error',
9+
'error stack',
10+
123,
11+
'error test',
12+
);
713
} catch (e) {
814
expect(e.type).toEqual('TEST_TypeError');
915
expect(e.message).toEqual('This is a test error');
@@ -32,4 +38,3 @@ describe('Custom Error', () => {
3238
}
3339
});
3440
});
35-

__tests__/layer.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ describe('Layer', () => {
3030
});
3131

3232
inputs.version = res.version;
33-
3433
});
3534

3635
test('should remove layer success', async () => {
@@ -43,7 +42,4 @@ describe('Layer', () => {
4342
const detail = await layer.getLayerDetail(inputs.name, inputs.version);
4443
expect(detail).toBeNull();
4544
});
46-
4745
});
48-
49-

__tests__/metrics.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,3 @@ describe('Metrics', () => {
2121
});
2222
});
2323
});
24-
25-

__tests__/pg.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,3 @@ describe('Postgresql', () => {
7676
expect(detail).toBeUndefined();
7777
});
7878
});
79-
80-
81-

__tests__/scf.test.js

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ describe('Scf', () => {
5555
cos: {
5656
name: 'cos-trigger',
5757
parameters: {
58-
bucket:
59-
`${process.env.BUCKET}-${process.env.TENCENT_APP_ID}.cos.${process.env.REGION}.myqcloud.com`,
58+
bucket: `${process.env.BUCKET}-${process.env.TENCENT_APP_ID}.cos.${process.env.REGION}.myqcloud.com`,
6059
enable: true,
6160
events: 'cos:ObjectCreated:*',
6261
filter: {
@@ -104,16 +103,20 @@ describe('Scf', () => {
104103

105104
beforeAll(async () => {
106105
const { fileSystemId } = await cfs.deploy(cfsInputs);
107-
inputs.cfs = [{
108-
localMountDir: '/mnt/',
109-
remoteMountDir: '/',
110-
cfsId: fileSystemId,
111-
}];
106+
inputs.cfs = [
107+
{
108+
localMountDir: '/mnt/',
109+
remoteMountDir: '/',
110+
cfsId: fileSystemId,
111+
},
112+
];
112113
const { name, version } = await layer.deploy(layerInputs);
113-
inputs.layers = [{
114-
name,
115-
version,
116-
}];
114+
inputs.layers = [
115+
{
116+
name,
117+
version,
118+
},
119+
];
117120
});
118121

119122
afterAll(async () => {
@@ -134,10 +137,14 @@ describe('Scf', () => {
134137
MemorySize: inputs.memorySize,
135138
Runtime: inputs.runtime,
136139
VpcConfig: { VpcId: vpcConfig.vpcId, SubnetId: vpcConfig.subnetId },
137-
Environment: { Variables: [{
138-
Key: 'TEST',
139-
Value: 'value',
140-
}]},
140+
Environment: {
141+
Variables: [
142+
{
143+
Key: 'TEST',
144+
Value: 'value',
145+
},
146+
],
147+
},
141148
Handler: inputs.handler,
142149
UseGpu: 'FALSE',
143150
Role: inputs.role,
@@ -223,17 +230,19 @@ describe('Scf', () => {
223230
AccessInfo: { Host: '', Vip: '' },
224231
Type: 'Event',
225232
CfsConfig: {
226-
CfsInsList: [{
227-
UserId: '10000',
228-
UserGroupId: '10000',
229-
CfsId: inputs.cfs[0].cfsId,
230-
MountInsId: inputs.cfs[0].cfsId,
231-
LocalMountDir: inputs.cfs[0].localMountDir,
232-
RemoteMountDir: inputs.cfs[0].remoteMountDir,
233-
IpAddress: expect.any(String),
234-
MountVpcId: inputs.vpcConfig.vpcId,
235-
MountSubnetId: inputs.vpcConfig.subnetId,
236-
}],
233+
CfsInsList: [
234+
{
235+
UserId: '10000',
236+
UserGroupId: '10000',
237+
CfsId: inputs.cfs[0].cfsId,
238+
MountInsId: inputs.cfs[0].cfsId,
239+
LocalMountDir: inputs.cfs[0].localMountDir,
240+
RemoteMountDir: inputs.cfs[0].remoteMountDir,
241+
IpAddress: expect.any(String),
242+
MountVpcId: inputs.vpcConfig.vpcId,
243+
MountSubnetId: inputs.vpcConfig.subnetId,
244+
},
245+
],
237246
},
238247
StatusReasons: [],
239248
RequestId: expect.any(String),
@@ -248,14 +257,14 @@ describe('Scf', () => {
248257
});
249258
expect(res).toEqual({
250259
Result: {
251-
'MemUsage': expect.any(Number),
252-
'Log': expect.any(String),
253-
'RetMsg': expect.any(String),
254-
'BillDuration': expect.any(Number),
255-
'FunctionRequestId': expect.any(String),
256-
'Duration': expect.any(Number),
257-
'ErrMsg': expect.any(String),
258-
'InvokeResult': expect.anything(),
260+
MemUsage: expect.any(Number),
261+
Log: expect.any(String),
262+
RetMsg: expect.any(String),
263+
BillDuration: expect.any(Number),
264+
FunctionRequestId: expect.any(String),
265+
Duration: expect.any(Number),
266+
ErrMsg: expect.any(String),
267+
InvokeResult: expect.anything(),
259268
},
260269
RequestId: expect.any(String),
261270
});

__tests__/tag.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const { Tag } = require('../src');
32

43
describe('Tag', () => {
@@ -10,7 +9,7 @@ describe('Tag', () => {
109
const inputs = {
1110
resource: `qcs::scf:${process.env.REGION}:uin/${process.env.TENCENT_UIN}:namespace/default/function/${functionName}`,
1211
replaceTags: { tagKey: 'tagValue' },
13-
deleteTags: { abcdd: 'def'},
12+
deleteTags: { abcdd: 'def' },
1413
};
1514
const tag = new Tag(credentials, process.env.REGION);
1615

@@ -24,4 +23,3 @@ describe('Tag', () => {
2423
expect(curTag.TagValue).toBe('tagValue');
2524
});
2625
});
27-

__tests__/vpc.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,3 @@ describe('Vpc', () => {
4848
}
4949
});
5050
});
51-

0 commit comments

Comments
 (0)