Skip to content

Commit 3544e4f

Browse files
committed
test(cd): reset appid after test cases
1 parent 7a88e9d commit 3544e4f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

test/bin/tsw/util/CD.test.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ describe('test CD module', () => {
2121
describe('test 发送openapiCD', async () => {
2222
const CHECK_INTERVAL = 200;
2323
const DEFAULT_CHECK_KEY = '1234';
24-
24+
let _appid;
2525
beforeEach(() => {
26+
_appid = config.appid;
2627
config.appid = 123;
2728
config.appkey = 123;
2829

@@ -36,8 +37,7 @@ describe('test CD module', () => {
3637
});
3738
});
3839
afterEach(() => {
39-
delete config.appid;
40-
delete config.appkey;
40+
config.appid = _appid;
4141
ajax.request.restore();
4242
});
4343
it('beforeOpenapi', async () => {
@@ -71,10 +71,12 @@ describe('test CD module', () => {
7171
return '123';
7272
}
7373
};
74+
const _appid = context.appid;
7475
context.appid = 'tsw123';
7576
await CD.openapi(req, {});
7677
expect(returnJson['code']).to.equal(-2);
7778
expect(returnJson['message']).to.equal('appid错误');
79+
context.appid = _appid;
7880
});
7981

8082
it('上下文不存在appid', async () => {
@@ -83,11 +85,12 @@ describe('test CD module', () => {
8385
return '';
8486
}
8587
};
88+
const _appid = context.appid;
8689
context.appid = '';
8790
await CD.openapi(req, {});
8891
expect(returnJson['code']).to.equal(-2);
8992
expect(returnJson['message']).to.equal('appid is required');
90-
93+
context.appid = _appid;
9194
});
9295

9396
it('上下文不存在appkey', async () => {
@@ -96,10 +99,12 @@ describe('test CD module', () => {
9699
return 'tsw123';
97100
}
98101
};
102+
const _appid = context.appid;
99103
context.appid = 'tsw123';
100104
await CD.openapi(req, {});
101105
expect(returnJson['code']).to.equal(-2);
102106
expect(returnJson['message']).to.equal('appkey is required');
107+
context.appid = _appid;
103108
});
104109

105110
it('appid不符合规范', async () => {
@@ -108,11 +113,13 @@ describe('test CD module', () => {
108113
return 'tsw123,';
109114
}
110115
};
116+
const _appid = context.appid;
111117
context.appid = 'tsw123,';
112118
context.appkey = 'tsw123,';
113119
await CD.openapi(req, {});
114120
expect(returnJson['code']).to.equal(-2);
115121
expect(returnJson['message']).to.equal('appid is required');
122+
context.appid = _appid;
116123
});
117124

118125
it('checkByCmem', async () => {
@@ -129,10 +136,12 @@ describe('test CD module', () => {
129136
return 'tsw123';
130137
}
131138
};
139+
const _appid = context.appid;
132140
context.appid = 'tsw123';
133141
context.appkey = 'tsw123';
134142
await CD.openapi(req, {});
135143
expect(returnJson['code']).to.equal(0);
144+
context.appid = _appid;
136145
});
137146

138147
});

0 commit comments

Comments
 (0)