提交 59436bb7 编写于 作者: X xinxin13

napi test

Signed-off-by: Nxinxin13 <xinxin13@huawei.com>
上级 be5b1818
...@@ -87,10 +87,10 @@ export default function actsBmsJsUnPermissionTest() { ...@@ -87,10 +87,10 @@ export default function actsBmsJsUnPermissionTest() {
await bundle.getApplicationInfo(BUNDLE_NAME_OTHER, DEFAULT_FLAG).then(data => { await bundle.getApplicationInfo(BUNDLE_NAME_OTHER, DEFAULT_FLAG).then(data => {
expect().assertFail(); expect().assertFail();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(INVALID_CODE); expect(err.code).assertEqual(INVALID_CODE);
}); });
bundle.getApplicationInfo(BUNDLE_NAME_OTHER, DEFAULT_FLAG, (err, data) => { bundle.getApplicationInfo(BUNDLE_NAME_OTHER, DEFAULT_FLAG, (err, data) => {
expect(err).assertEqual(INVALID_CODE); expect(err.code).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined); expect(data).assertEqual(undefined);
done(); done();
}); });
......
...@@ -46,10 +46,10 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -46,10 +46,10 @@ describe('ActsBmsJsUnPermissionTest', function () {
await bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, userId).then(data => { await bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, userId).then(data => {
expect().assertFail(); expect().assertFail();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(INVALID_CODE); expect(err.code).assertEqual(INVALID_CODE);
}); });
bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, userId, (err, data) => { bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, userId, (err, data) => {
expect(err).assertEqual(INVALID_CODE); expect(err.code).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined); expect(data).assertEqual(undefined);
done(); done();
}); });
...@@ -143,10 +143,10 @@ describe('ActsBmsJsUnPermissionTest', function () { ...@@ -143,10 +143,10 @@ describe('ActsBmsJsUnPermissionTest', function () {
await bundle.getLaunchWantForBundle(LAUNCHER_BUNDLE_NAME).then(data => { await bundle.getLaunchWantForBundle(LAUNCHER_BUNDLE_NAME).then(data => {
expect().assertFail(); expect().assertFail();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(INVALID_CODE); expect(err.code).assertEqual(INVALID_CODE);
}); });
bundle.getLaunchWantForBundle(LAUNCHER_BUNDLE_NAME, (err, data) => { bundle.getLaunchWantForBundle(LAUNCHER_BUNDLE_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE); expect(err.code).assertEqual(INVALID_CODE);
expect(data).assertEqual(undefined); expect(data).assertEqual(undefined);
done(); done();
}); });
......
...@@ -44,7 +44,7 @@ export default function getLaunchWantForBundle() { ...@@ -44,7 +44,7 @@ export default function getLaunchWantForBundle() {
expect(err).assertFail(); expect(err).assertFail();
}); });
bundleMgr.getLaunchWantForBundle(NAME1, (err, res) => { bundleMgr.getLaunchWantForBundle(NAME1, (err, res) => {
expect(err).assertEqual(0); expect(err.code).assertEqual(0);
expect(res.bundleName).assertEqual(NAME1); expect(res.bundleName).assertEqual(NAME1);
expect(res.abilityName).assertEqual(ABILITYNAME1); expect(res.abilityName).assertEqual(ABILITYNAME1);
expect(res.deviceId).assertEqual(''); expect(res.deviceId).assertEqual('');
...@@ -74,7 +74,7 @@ export default function getLaunchWantForBundle() { ...@@ -74,7 +74,7 @@ export default function getLaunchWantForBundle() {
expect(err).assertFail(); expect(err).assertFail();
}); });
bundleMgr.getLaunchWantForBundle(NAME2, (err, res) => { bundleMgr.getLaunchWantForBundle(NAME2, (err, res) => {
expect(err).assertEqual(0); expect(err.code).assertEqual(0);
expect(res.bundleName).assertEqual(NAME2); expect(res.bundleName).assertEqual(NAME2);
expect(res.abilityName).assertEqual(ABILITYNAME2); expect(res.abilityName).assertEqual(ABILITYNAME2);
expect(res.deviceId).assertEqual(''); expect(res.deviceId).assertEqual('');
...@@ -96,11 +96,11 @@ export default function getLaunchWantForBundle() { ...@@ -96,11 +96,11 @@ export default function getLaunchWantForBundle() {
await bundleMgr.getLaunchWantForBundle(NAME3).then(res => { await bundleMgr.getLaunchWantForBundle(NAME3).then(res => {
expect().assertFail(); expect().assertFail();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(1); expect(err.code).assertEqual(1);
}); });
bundleMgr.getLaunchWantForBundle(NAME3, (err, res) => { bundleMgr.getLaunchWantForBundle(NAME3, (err, res) => {
if (err) { if (err) {
expect(err).assertEqual(1); expect(err.code).assertEqual(1);
done(); done();
return; return;
} }
...@@ -122,11 +122,11 @@ export default function getLaunchWantForBundle() { ...@@ -122,11 +122,11 @@ export default function getLaunchWantForBundle() {
await bundleMgr.getLaunchWantForBundle(null).then(res => { await bundleMgr.getLaunchWantForBundle(null).then(res => {
expect().assertFail(); expect().assertFail();
}).catch(err => { }).catch(err => {
expect(err).assertEqual(1); expect(err.code).assertEqual(1);
}); });
bundleMgr.getLaunchWantForBundle(null, (err, res) => { bundleMgr.getLaunchWantForBundle(null, (err, res) => {
if (err) { if (err) {
expect(err).assertEqual(1); expect(err.code).assertEqual(1);
done(); done();
return; return;
} }
......
...@@ -42,7 +42,7 @@ export default function IsApplicationEnabledETSUnit() { ...@@ -42,7 +42,7 @@ export default function IsApplicationEnabledETSUnit() {
Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => { Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => {
let timeNewStamp = Utils.getNowTime(); let timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0200]', timeOldStamp, timeNewStamp); Utils.getDurationTime('[context_isApplicationEnabled_test_0200]', timeOldStamp, timeNewStamp);
expect(error).assertEqual(undefined); expect(error.code).assertEqual(undefined);
expect(data).assertTrue(); expect(data).assertTrue();
done(); done();
}); });
...@@ -70,13 +70,13 @@ export default function IsApplicationEnabledETSUnit() { ...@@ -70,13 +70,13 @@ export default function IsApplicationEnabledETSUnit() {
expect(error).assertEqual(2); expect(error).assertEqual(2);
}); });
Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR, (error, data) => { Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR, (error, data) => {
expect(error).assertEqual(undefined); expect(error.code).assertEqual(undefined);
expect(data).assertFalse(); expect(data).assertFalse();
Bundle.isApplicationEnabled("", (error, data) => { Bundle.isApplicationEnabled("", (error, data) => {
expect(error).assertEqual(undefined); expect(error.code).assertEqual(undefined);
expect(data).assertFalse(); expect(data).assertFalse();
Bundle.isApplicationEnabled(undefined, (error, data) => { Bundle.isApplicationEnabled(undefined, (error, data) => {
expect(error).assertEqual(2); expect(error.code).assertEqual(2);
expect(data).assertEqual(undefined); expect(data).assertEqual(undefined);
done(); done();
}); });
...@@ -98,7 +98,7 @@ export default function IsApplicationEnabledETSUnit() { ...@@ -98,7 +98,7 @@ export default function IsApplicationEnabledETSUnit() {
}); });
timeOldStamp = await Utils.getNowTime(); timeOldStamp = await Utils.getNowTime();
Bundle.isApplicationEnabled(BUNDLE_NAME_OTHER, (error, data) => { Bundle.isApplicationEnabled(BUNDLE_NAME_OTHER, (error, data) => {
expect(error).assertEqual(undefined); expect(error.code).assertEqual(undefined);
expect(data).assertTrue(); expect(data).assertTrue();
done(); done();
}); });
......
...@@ -254,7 +254,7 @@ export default function applicationBundleJsunit() { ...@@ -254,7 +254,7 @@ export default function applicationBundleJsunit() {
}).catch((error) => { }).catch((error) => {
console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise error is: ' + error); console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise error is: ' + error);
errors = error errors = error
expect(errors).assertEqual(1); expect(errors.code).assertEqual(1);
}); });
let endTime = Utils.getNowTime(); let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_002, startTime, endTime); Utils.getDurationTime(TAG_TEST_0600_002, startTime, endTime);
...@@ -284,7 +284,7 @@ export default function applicationBundleJsunit() { ...@@ -284,7 +284,7 @@ export default function applicationBundleJsunit() {
console.info(TAG_TEST_0600_003 + 'noUserId promise data is: ' + data); console.info(TAG_TEST_0600_003 + 'noUserId promise data is: ' + data);
expectData(TAG_TEST_0600_003, data); expectData(TAG_TEST_0600_003, data);
getApplicationInfoSuccess_plus(TAG_TEST_0600_003, data); getApplicationInfoSuccess_plus(TAG_TEST_0600_003, data);
expect(err).assertEqual(0); expect(err.code).assertEqual(0);
done(); done();
}); });
}); });
...@@ -319,7 +319,7 @@ export default function applicationBundleJsunit() { ...@@ -319,7 +319,7 @@ export default function applicationBundleJsunit() {
await Bundle.getApplicationInfo(BUNDLE_NOTEXIST, FLAG_DEFAULT).then((data) => { await Bundle.getApplicationInfo(BUNDLE_NOTEXIST, FLAG_DEFAULT).then((data) => {
expect(data).assertFail(); expect(data).assertFail();
}).catch((error) => { }).catch((error) => {
expect(error).assertEqual(1); expect(error.code).assertEqual(1);
let endTime = Utils.getNowTime(); let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime); Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime);
}); });
...@@ -327,7 +327,7 @@ export default function applicationBundleJsunit() { ...@@ -327,7 +327,7 @@ export default function applicationBundleJsunit() {
await Bundle.getApplicationInfo(BUNDLE_NOTEXIST, FLAG_DEFAULT, (err, data) => { await Bundle.getApplicationInfo(BUNDLE_NOTEXIST, FLAG_DEFAULT, (err, data) => {
let endTime = Utils.getNowTime(); let endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime); Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime);
expect(err).assertEqual(1); expect(err.code).assertEqual(1);
expect(JSON.stringify(data)).assertEqual(undefined); expect(JSON.stringify(data)).assertEqual(undefined);
done(); done();
}); });
...@@ -342,7 +342,7 @@ export default function applicationBundleJsunit() { ...@@ -342,7 +342,7 @@ export default function applicationBundleJsunit() {
await Bundle.getApplicationInfo('', FLAG_DEFAULT).then((data) => { await Bundle.getApplicationInfo('', FLAG_DEFAULT).then((data) => {
expect(data).assertFail(); expect(data).assertFail();
}).catch((error) => { }).catch((error) => {
expect(error).assertEqual(1); expect(error.code).assertEqual(1);
}); });
await Bundle.getApplicationInfo(null, FLAG_DEFAULT).then((data) => { await Bundle.getApplicationInfo(null, FLAG_DEFAULT).then((data) => {
expect(data).assertFail(); expect(data).assertFail();
...@@ -352,16 +352,16 @@ export default function applicationBundleJsunit() { ...@@ -352,16 +352,16 @@ export default function applicationBundleJsunit() {
await Bundle.getApplicationInfo(BUNDLE_NAME, null).then((data) => { await Bundle.getApplicationInfo(BUNDLE_NAME, null).then((data) => {
expect(data).assertFail(); expect(data).assertFail();
}).catch((error) => { }).catch((error) => {
expect(error).assertEqual(1); expect(error.code).assertEqual(1);
}); });
Bundle.getApplicationInfo('', FLAG_DEFAULT, (err, data) => { Bundle.getApplicationInfo('', FLAG_DEFAULT, (err, data) => {
expect(err).assertEqual(1); expect(err.code).assertEqual(1);
expect(JSON.stringify(data)).assertEqual(undefined); expect(JSON.stringify(data)).assertEqual(undefined);
Bundle.getApplicationInfo(null, FLAG_DEFAULT, (err, data) => { Bundle.getApplicationInfo(null, FLAG_DEFAULT, (err, data) => {
expect(err).assertEqual(1); expect(err.code).assertEqual(1);
expect(data).assertEqual("type mismatch"); expect(data).assertEqual("type mismatch");
Bundle.getApplicationInfo(BUNDLE_NAME, null, (err, data) => { Bundle.getApplicationInfo(BUNDLE_NAME, null, (err, data) => {
expect(err).assertEqual(1); expect(err.code).assertEqual(1);
expect(data).assertEqual("type mismatch"); expect(data).assertEqual("type mismatch");
done(); done();
}); });
...@@ -393,7 +393,7 @@ export default function applicationBundleJsunit() { ...@@ -393,7 +393,7 @@ export default function applicationBundleJsunit() {
Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.getApplicationInfo(BUNDLE_NAME,
Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT, (error, data) => { Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT, (error, data) => {
expect(data.fingerprint).assertEqual(TEST_DEMO); expect(data.fingerprint).assertEqual(TEST_DEMO);
expect(error).assertEqual(0); expect(error.code).assertEqual(0);
done(); done();
}); });
}); });
......
...@@ -909,7 +909,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -909,7 +909,7 @@ describe('ActsBundleManagerTest', function () {
done(); done();
}).catch(err => { }).catch(err => {
console.info("testGetApplicationInfoNotExistCallback err" + JSON.stringify(err)); console.info("testGetApplicationInfoNotExistCallback err" + JSON.stringify(err));
expect(err).assertEqual(1); expect(err.code).assertEqual(1);
done(); done();
}); });
}) })
...@@ -924,7 +924,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -924,7 +924,7 @@ describe('ActsBundleManagerTest', function () {
userId, (error, datainfo) => { userId, (error, datainfo) => {
if (error) { if (error) {
console.info("testGetApplicationInfoNotExistPromise fail" + JSON.stringify(error)); console.info("testGetApplicationInfoNotExistPromise fail" + JSON.stringify(error));
expect(error).assertEqual(1); expect(error.code).assertEqual(1);
done(); done();
return; return;
} }
...@@ -947,7 +947,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -947,7 +947,7 @@ describe('ActsBundleManagerTest', function () {
done(); done();
}).catch(error => { }).catch(error => {
console.info("testGetApplicationInfoInvalidParamPromise err" + JSON.stringify(error)); console.info("testGetApplicationInfoInvalidParamPromise err" + JSON.stringify(error));
expect(error).assertEqual(1); expect(error.code).assertEqual(1);
done(); done();
}); });
}) })
...@@ -962,7 +962,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -962,7 +962,7 @@ describe('ActsBundleManagerTest', function () {
userId, (error, datainfo) => { userId, (error, datainfo) => {
if (error) { if (error) {
console.info("testGetApplicationInfoInvalidParamCallback fail" + JSON.stringify(error)); console.info("testGetApplicationInfoInvalidParamCallback fail" + JSON.stringify(error));
expect(error).assertEqual(1); expect(error.code).assertEqual(1);
done(); done();
return; return;
} }
......
...@@ -967,7 +967,7 @@ it('ACTS_ZipFile_4500', 0, async function (done) { ...@@ -967,7 +967,7 @@ it('ACTS_ZipFile_4500', 0, async function (done) {
done(); done();
}).catch((err) => { }).catch((err) => {
console.log("ACTS_ZipFile_4500 err: " + err); console.log("ACTS_ZipFile_4500 err: " + err);
expect(err).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO); expect(err.code).assertEqual(zlib.ErrorCode.ERROR_CODE_ERRNO);
done(); done();
}) })
}).catch(function (error) { }).catch(function (error) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册