提交 dacfa008 编写于 作者: Y yangzhouwei

modify storage js unit.

Signed-off-by: Nyangzhouwei <yangzhouwei1@huawei.com>
上级 fc180e3f
......@@ -49,9 +49,9 @@ describe('storageTest', function () {
})
/**
* @tc.name has callback interface test
* @tc.name has string callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0020
* @tc.desc has callback interface test
* @tc.desc has string callback interface test
*/
it('testHasKey0032', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
......@@ -61,6 +61,58 @@ describe('storageTest', function () {
done();
})
/**
* @tc.name has int callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0130
* @tc.desc has int callback interface test
*/
it('testHasKey0033', 0, async function (done) {
mPref.putSync(KEY_TEST_INT_ELEMENT, 1);
await mPref.has(KEY_TEST_INT_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret);
})
done();
})
/**
* @tc.name has float callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0140
* @tc.desc has float callback interface test
*/
it('testHasKey0034', 0, async function (done) {
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 1.1);
await mPref.has(KEY_TEST_FLOAT_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret);
})
done();
})
/**
* @tc.name has long callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0150
* @tc.desc has long callback interface test
*/
it('testHasKey0035', 0, async function (done) {
mPref.putSync(KEY_TEST_LONG_ELEMENT, 0);
await mPref.has(KEY_TEST_LONG_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret);
})
done();
})
/**
* @tc.name has boolean callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0160
* @tc.desc has boolean callback interface test
*/
it('testHasKey0036', 0, async function (done) {
mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, false);
await mPref.has(KEY_TEST_BOOLEAN_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret);
})
done();
})
/**
* @tc.name get defaultValue callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0030
......
// @ts-nocheck
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -68,12 +69,14 @@ describe('storageTest', function () {
*/
it('testRemoveStorageFromCache001', 0, function () {
let perf = storage.getStorageSync('/data/test_storage1');
perf = null;
perf.putSync('test', 2);
try {
storage.removeStorageFromCacheSync('/data/test_storage1');
} catch (e) {
expect(null).assertFail();
}
var value = mPref.getSync('test', 0);
expect(value).assertEqual(0);
})
/**
......@@ -100,12 +103,16 @@ describe('storageTest', function () {
*/
it('testDeleteStorageHelper001', 0, function () {
let perf = storage.getStorageSync('/data/test_storage3');
perf = null;
try {
storage.deleteStorageSync('/data/test_storage3');
} catch (e) {
expect(null).assertFail();
}
try {
perf.putSync("int", 3);
expect(null).assertFail();
} catch (e) {
}
})
/**
......
......@@ -53,9 +53,9 @@ describe('storageTest', function () {
})
/**
* @tc.name has promise interface test
* @tc.name has string interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0020
* @tc.desc has promise interface test
* @tc.desc has string interface test
*/
it('testHasKey0031', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
......@@ -70,9 +70,77 @@ describe('storageTest', function () {
})
/**
* @tc.name get defalut promise interface test
* @tc.name has int interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0140
* @tc.desc has int interface test
*/
it('testHasKey0032', 0, async function (done) {
mPref.putSync(KEY_TEST_INT_ELEMENT, 1);
const promise = mPref.has(KEY_TEST_INT_ELEMENT);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name has float interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0150
* @tc.desc has float interface test
*/
it('testHasKey0033', 0, async function (done) {
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 2.0);
const promise = mPref.has(KEY_TEST_FLOAT_ELEMENT);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name has boolean interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0160
* @tc.desc has boolean interface test
*/
it('testHasKey0034', 0, async function (done) {
mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, false);
const promise = mPref.has(KEY_TEST_BOOLEAN_ELEMENT);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name has long interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0170
* @tc.desc has long interface test
*/
it('testHasKey0035', 0, async function (done) {
mPref.putSync(KEY_TEST_LONG_ELEMENT, 0);
const promise = mPref.has(KEY_TEST_LONG_ELEMENT);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get string promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0030
* @tc.desc deleteStorage interface test
* @tc.desc get string promise interface test
*/
it('testGetDefValue0061', 0, async function (done) {
mPref.clearSync();
......@@ -160,9 +228,9 @@ describe('storageTest', function () {
})
/**
* @tc.name get String promise interface test
* @tc.name put boolean promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0090
* @tc.desc get String promise interface test
* @tc.desc put boolean promise interface test
*/
it('testPutBoolean0121', 0, async function (done) {
mPref.clearSync();
......
......@@ -54,9 +54,9 @@ describe('storageTest', function () {
})
/**
* @tc.name has sync inteface test
* @tc.name put string sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0020
* @tc.desc has sync inteface test
* @tc.desc put string sync interface test
*/
it('testHasKey003', 0, function () {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
......@@ -64,19 +64,59 @@ describe('storageTest', function () {
})
/**
* @tc.name get boolean sync inteface test
* @tc.name put int sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0170
* @tc.desc put int sync interface test
*/
it('testHasKey004', 0, function () {
mPref.putSync(KEY_TEST_INT_ELEMENT, 1);
expect(true).assertEqual(mPref.hasSync(KEY_TEST_INT_ELEMENT));
})
/**
* @tc.name put boolean sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0180
* @tc.desc put boolean sync interface test
*/
it('testHasKey005', 0, function () {
mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, false);
expect(true).assertEqual(mPref.hasSync(KEY_TEST_BOOLEAN_ELEMENT));
})
/**
* @tc.name put long sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0190
* @tc.desc put long sync interface test
*/
it('testHasKey006', 0, function () {
mPref.putSync(KEY_TEST_LONG_ELEMENT, 0);
expect(true).assertEqual(mPref.hasSync(KEY_TEST_LONG_ELEMENT));
})
/**
* @tc.name put float sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0200
* @tc.desc put float sync interface test
*/
it('testHasKey007', 0, function () {
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 1.1);
expect(true).assertEqual(mPref.hasSync(KEY_TEST_FLOAT_ELEMENT));
})
/**
* @tc.name put boolean sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0030
* @tc.desc get boolean sync inteface test
* @tc.desc put boolean sync interface test
*/
it('testGetBoolean005', 0, function () {
mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, true);
expect(true).assertEqual(mPref.hasSync(KEY_TEST_BOOLEAN_ELEMENT));
mPref.putSync(KEY_TEST_LONG_ELEMENT, true);
expect(true).assertEqual(mPref.hasSync(KEY_TEST_LONG_ELEMENT));
})
/**
* @tc.name get defaltValue sync inteface test
* @tc.name get defaultValue sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0040
* @tc.desc get defaltValue sync inteface test
* @tc.desc get defaultValue sync interface test
*/
it('testGetDefValue006', 0, function () {
mPref.clearSync();
......@@ -88,32 +128,32 @@ describe('storageTest', function () {
})
/**
* @tc.name get float sync inteface test
* @tc.name put float sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0050
* @tc.desc get float sync inteface test
* @tc.desc put float sync interface test
*/
it('testGetFloat007', 0, function () {
mPref.clearSync();
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0);
expect(3.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0), 0);
expect(0.0).assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, 0.0), 0);
expect(3.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
expect(0.0).assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, 0.0));
})
/**
* @tc.name get int sync inteface test
* @tc.name put int sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0060
* @tc.desc get int sync inteface test
* @tc.desc put int sync interface test
*/
it('testGetInt008', 0, function () {
mPref.clearSync();
mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
expect(3).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0.0), 0);
expect(3).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0.0));
})
/**
* @tc.name get long sync inteface test
* @tc.name put long sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0070
* @tc.desc get long sync inteface test
* @tc.desc put long sync interface test
*/
it('testGetLong009', 0, function () {
mPref.clearSync();
......@@ -123,9 +163,9 @@ describe('storageTest', function () {
})
/**
* @tc.name get String sync inteface test
* @tc.name put String & int sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0080
* @tc.desc get String sync inteface test
* @tc.desc put String & int sync interface test
*/
it('testGetString10', 0, function () {
mPref.clearSync();
......@@ -137,9 +177,9 @@ describe('storageTest', function () {
})
/**
* @tc.name put float sync inteface test
* @tc.name put boolean sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0090
* @tc.desc put float sync inteface test
* @tc.desc put boolean sync interface test
*/
it('testPutBoolean012', 0, function () {
mPref.clearSync();
......@@ -150,9 +190,9 @@ describe('storageTest', function () {
})
/**
* @tc.name put float sync inteface test
* @tc.name put float sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0100
* @tc.desc put float sync inteface test
* @tc.desc put float sync interface test
*/
it('testPutFloat013', 0, function () {
mPref.clearSync();
......@@ -163,9 +203,9 @@ describe('storageTest', function () {
})
/**
* @tc.name put int sync inteface test
* @tc.name put int sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0110
* @tc.desc put int sync inteface test
* @tc.desc put int sync interface test
*/
it('testPutInt014', 0, function () {
mPref.clearSync();
......@@ -176,9 +216,9 @@ describe('storageTest', function () {
})
/**
* @tc.name put long sync inteface test
* @tc.name put long sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0120
* @tc.desc put long sync inteface test
* @tc.desc put long sync interface test
*/
it('testPutLong015', 0, function () {
mPref.clearSync();
......@@ -189,9 +229,9 @@ describe('storageTest', function () {
})
/**
* @tc.name put String sync inteface test
* @tc.name put String sync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0130
* @tc.desc put String sync inteface test
* @tc.desc put String sync interface test
*/
it('testPutString016', 0, function () {
mPref.clearSync();
......@@ -203,9 +243,9 @@ describe('storageTest', function () {
})
/**
* @tc.name on interface test
* @tc.name put interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0140
* @tc.desc on interface test
* @tc.desc put interface test
*/
it('testRegisterObserver001', 0, function () {
mPref.clearSync();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册