提交 ad49d27c 编写于 作者: B bayanxing

testClearInterval 修复

Signed-off-by: Nbayanxing <bayanxing@kaihong.com>
上级 11a5a712
...@@ -19,7 +19,7 @@ import router from '@system.router'; ...@@ -19,7 +19,7 @@ import router from '@system.router';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
export default function basicabilityapi() { export default function basicabilityapi() {
describe('basicabilityapi', function () { describe('basicabilityapi', function () {
let testResult; let testResult;
let testResultFail; let testResultFail;
let test; let test;
...@@ -63,21 +63,25 @@ describe('basicabilityapi', function () { ...@@ -63,21 +63,25 @@ describe('basicabilityapi', function () {
it('testClearInterval', 0, async function(done) { it('testClearInterval', 0, async function(done) {
console.info('testClearInterval START'); console.info('testClearInterval START');
let res = 0; let res = 0;
let testTimes = 5
let intervalID = -1; let intervalID = -1;
let promise1 = new Promise((resolve, reject) => { let promise1 = new Promise((resolve, reject) => {
intervalID = setInterval(function () { intervalID = setInterval(function () {
if(res === testTimes ){
clearInterval(intervalID);
}
res++; res++;
console.info('testClearInterval res = ' + res); console.info('testClearInterval res = ' + res);
resolve(); resolve();
}, 100); }, 100);
}); });
Promise.all([promise1]).then(() => { let promise2 = new Promise((resolve, reject) => {
setTimeout(function () {
console.info('[clearInterval] start');
clearInterval(intervalID);
console.info('[clearInterval] end');
resolve();
}, 600);
});
Promise.all([promise1, promise2]).then(() => {
console.info('testClearInterval finally'); console.info('testClearInterval finally');
expect(testTimes).assertEqual(res); expect(5).assertEqual(res);
console.info('testClearInterval END'); console.info('testClearInterval END');
done(); done();
}); });
...@@ -487,6 +491,7 @@ describe('basicabilityapi', function () { ...@@ -487,6 +491,7 @@ describe('basicabilityapi', function () {
}, 1000); }, 1000);
}); });
/** /**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1500 * @tc.number SUB_ACE_BASICABILITY_JS_API_1500
* @tc.name testRequestAnimationFrame * @tc.name testRequestAnimationFrame
...@@ -519,5 +524,5 @@ describe('basicabilityapi', function () { ...@@ -519,5 +524,5 @@ describe('basicabilityapi', function () {
done(); done();
}, 1000); }, 1000);
}); });
}); });
} }
# This file is automatically generated by DevEco Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file should *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# For customization when using a Version Control System, please read the header note.
sdk.dir=D:/beta3Sdk
nodejs.dir=D:/software/DevEco Studio 3.0.0.900/tools/nodejs
npm.dir=D:/software/DevEco Studio 3.0.0.900/tools/nodejs
\ No newline at end of file
{
"lockfileVersion": 1
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册