Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
2f1d3553
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2f1d3553
编写于
10月 13, 2021
作者:
O
openharmony_ci
提交者:
Gitee
10月 13, 2021
浏览文件
操作
浏览文件
下载
差异文件
!874 modify distributeddatamgrjstest test suite error
Merge pull request !874 from wangkun/master
上级
6778be3d
01d6d951
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
234 addition
and
125 deletion
+234
-125
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStoreCallbackJsunit.test.js
.../main/js/default/test/SingleKvStoreCallbackJsunit.test.js
+66
-0
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStorePromiseJsunit.test.js
...c/main/js/default/test/SingleKvStorePromiseJsunit.test.js
+168
-125
未找到文件。
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStoreCallbackJsunit.test.js
浏览文件 @
2f1d3553
...
@@ -19,15 +19,21 @@ const KEY_TEST_INT_ELEMENT = 'key_test_int_2';
...
@@ -19,15 +19,21 @@ const KEY_TEST_INT_ELEMENT = 'key_test_int_2';
const
KEY_TEST_FLOAT_ELEMENT
=
'
key_test_float_2
'
;
const
KEY_TEST_FLOAT_ELEMENT
=
'
key_test_float_2
'
;
const
KEY_TEST_BOOLEAN_ELEMENT
=
'
key_test_boolean_2
'
;
const
KEY_TEST_BOOLEAN_ELEMENT
=
'
key_test_boolean_2
'
;
const
KEY_TEST_STRING_ELEMENT
=
'
key_test_string_2
'
;
const
KEY_TEST_STRING_ELEMENT
=
'
key_test_string_2
'
;
const
KEY_TEST_SYNC_ELEMENT
=
'
key_test_sync
'
;
const
VALUE_TEST_INT_ELEMENT
=
1234
;
const
VALUE_TEST_INT_ELEMENT
=
1234
;
const
VALUE_TEST_FLOAT_ELEMENT
=
4321.12
;
const
VALUE_TEST_FLOAT_ELEMENT
=
4321.12
;
const
VALUE_TEST_BOOLEAN_ELEMENT
=
true
;
const
VALUE_TEST_BOOLEAN_ELEMENT
=
true
;
const
VALUE_TEST_STRING_ELEMENT
=
'
value-string-002
'
;
const
VALUE_TEST_STRING_ELEMENT
=
'
value-string-002
'
;
const
VALUE_TEST_SYNC_ELEMENT
=
'
value-string-001
'
;
const
SINGLE_VERSION
=
1
;
const
SINGLE_VERSION
=
1
;
const
SECURITY_LEVEL
=
3
;
const
SECURITY_LEVEL
=
3
;
const
PULL_ONLY
=
0
;
const
PUSH_ONLY
=
1
;
const
PUSH_PULL
=
2
;
var
kvManager
=
null
;
var
kvManager
=
null
;
var
kvStore
=
null
;
var
kvStore
=
null
;
...
@@ -324,4 +330,64 @@ describe('KvStoreTest', function () {
...
@@ -324,4 +330,64 @@ describe('KvStoreTest', function () {
}
}
done
();
done
();
})
})
it
(
'
testOnSyncComplete101
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
syncComplete
'
,
function
(
data
)
{
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync101
'
,
VALUE_TEST_SYNC_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
PULL_ONLY
;
kvStore
.
sync
(
devices
,
mode
,
10
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testOnSyncComplete102
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
syncComplete
'
,
function
(
data
)
{
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync101
'
,
VALUE_TEST_SYNC_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
PUSH_ONLY
;
kvStore
.
sync
(
devices
,
mode
,
10
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testOnSyncComplete103
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
syncComplete
'
,
function
(
data
)
{
expect
(
true
).
assertEqual
(
data
!=
null
);
});
await
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync101
'
,
VALUE_TEST_SYNC_ELEMENT
,
function
(
err
,
data
)
{
if
(
err
!=
undefined
)
{
expect
(
null
).
assertFail
();
}
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
PUSH_PULL
;
kvStore
.
sync
(
devices
,
mode
,
10
);
});
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
})
})
\ No newline at end of file
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SingleKvStorePromiseJsunit.test.js
浏览文件 @
2f1d3553
...
@@ -19,17 +19,26 @@ const KEY_TEST_INT_ELEMENT = 'key_test_int';
...
@@ -19,17 +19,26 @@ const KEY_TEST_INT_ELEMENT = 'key_test_int';
const
KEY_TEST_FLOAT_ELEMENT
=
'
key_test_float
'
;
const
KEY_TEST_FLOAT_ELEMENT
=
'
key_test_float
'
;
const
KEY_TEST_BOOLEAN_ELEMENT
=
'
key_test_boolean
'
;
const
KEY_TEST_BOOLEAN_ELEMENT
=
'
key_test_boolean
'
;
const
KEY_TEST_STRING_ELEMENT
=
'
key_test_string
'
;
const
KEY_TEST_STRING_ELEMENT
=
'
key_test_string
'
;
const
KEY_TEST_SYNC_ELEMENT
=
'
key_test_sync
'
;
const
VALUE_TEST_INT_ELEMENT
=
123
;
const
VALUE_TEST_INT_ELEMENT
=
123
;
const
VALUE_TEST_FLOAT_ELEMENT
=
321.12
;
const
VALUE_TEST_FLOAT_ELEMENT
=
321.12
;
const
VALUE_TEST_BOOLEAN_ELEMENT
=
true
;
const
VALUE_TEST_BOOLEAN_ELEMENT
=
true
;
const
VALUE_TEST_STRING_ELEMENT
=
'
value-string-001
'
;
const
VALUE_TEST_STRING_ELEMENT
=
'
value-string-001
'
;
const
VALUE_TEST_SYNC_ELEMENT
=
'
value-string-001
'
;
const
SINGLE_VERSION
=
1
;
const
SINGLE_VERSION
=
1
;
const
SECURITY_LEVEL
=
3
;
const
SECURITY_LEVEL
=
3
;
const
PULL_ONLY
=
0
;
const
PUSH_ONLY
=
1
;
const
PUSH_PULL
=
2
;
var
kvManager
=
null
;
var
kvManager
=
null
;
var
kvStore
=
null
;
var
kvStore
=
null
;
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
}
describe
(
'
KvStoreTest
'
,
function
()
{
describe
(
'
KvStoreTest
'
,
function
()
{
const
config
=
{
const
config
=
{
bundleName
:
'
ohos.acts.distributeddatamgr
'
,
bundleName
:
'
ohos.acts.distributeddatamgr
'
,
...
@@ -58,7 +67,7 @@ describe('KvStoreTest', function () {
...
@@ -58,7 +67,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -75,7 +84,7 @@ describe('KvStoreTest', function () {
...
@@ -75,7 +84,7 @@ describe('KvStoreTest', function () {
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
}
}
done
();
done
();
...
@@ -90,7 +99,7 @@ describe('KvStoreTest', function () {
...
@@ -90,7 +99,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -104,7 +113,7 @@ describe('KvStoreTest', function () {
...
@@ -104,7 +113,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -118,7 +127,7 @@ describe('KvStoreTest', function () {
...
@@ -118,7 +127,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -132,7 +141,7 @@ describe('KvStoreTest', function () {
...
@@ -132,7 +141,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -147,7 +156,7 @@ describe('KvStoreTest', function () {
...
@@ -147,7 +156,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
){
}
catch
(
e
){
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -162,18 +171,16 @@ describe('KvStoreTest', function () {
...
@@ -162,18 +171,16 @@ describe('KvStoreTest', function () {
}
}
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
+
'
002
'
,
str
);
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
+
'
002
'
,
str
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_STRING_ELEMENT
+
'
002
'
);
const
promise1
=
kvStore
.
get
(
KEY_TEST_STRING_ELEMENT
+
'
002
'
);
promise1
.
then
((
data
)
=>
{
promise1
.
then
((
data
)
=>
{
expect
(
str
).
assertEqual
(
data
);
expect
(
str
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -187,7 +194,7 @@ describe('KvStoreTest', function () {
...
@@ -187,7 +194,7 @@ describe('KvStoreTest', function () {
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
});
});
await
promise1
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
}
}
done
();
done
();
...
@@ -200,7 +207,7 @@ describe('KvStoreTest', function () {
...
@@ -200,7 +207,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -211,17 +218,16 @@ describe('KvStoreTest', function () {
...
@@ -211,17 +218,16 @@ describe('KvStoreTest', function () {
try
{
try
{
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
001
'
,
VALUE_TEST_INT_ELEMENT
);
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
001
'
,
VALUE_TEST_INT_ELEMENT
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
001
'
);
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
001
'
);
promise1
.
then
((
data
)
=>
{
promise1
.
then
((
data
)
=>
{
expect
(
VALUE_TEST_INT_ELEMENT
).
assertEqual
(
data
);
expect
(
VALUE_TEST_INT_ELEMENT
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -233,18 +239,16 @@ describe('KvStoreTest', function () {
...
@@ -233,18 +239,16 @@ describe('KvStoreTest', function () {
var
intValue
=
987654321
;
var
intValue
=
987654321
;
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
002
'
,
intValue
);
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
002
'
,
intValue
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
002
'
);
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
002
'
);
promise1
.
then
((
data
)
=>
{
promise1
.
then
((
data
)
=>
{
expect
(
intValue
).
assertEqual
(
data
);
expect
(
intValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -256,18 +260,16 @@ describe('KvStoreTest', function () {
...
@@ -256,18 +260,16 @@ describe('KvStoreTest', function () {
var
intValue
=
Number
.
MAX_VALUE
;
var
intValue
=
Number
.
MAX_VALUE
;
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
003
'
,
intValue
);
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
003
'
,
intValue
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
003
'
);
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
003
'
);
promise1
.
then
((
data
)
=>
{
promise1
.
then
((
data
)
=>
{
expect
(
intValue
).
assertEqual
(
data
);
expect
(
intValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -279,18 +281,16 @@ describe('KvStoreTest', function () {
...
@@ -279,18 +281,16 @@ describe('KvStoreTest', function () {
var
intValue
=
Number
.
MIN_VALUE
;
var
intValue
=
Number
.
MIN_VALUE
;
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
004
'
,
intValue
);
const
promise
=
kvStore
.
put
(
KEY_TEST_INT_ELEMENT
+
'
004
'
,
intValue
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
004
'
);
const
promise1
=
kvStore
.
get
(
KEY_TEST_INT_ELEMENT
+
'
004
'
);
promise1
.
then
((
data
)
=>
{
promise1
.
then
((
data
)
=>
{
expect
(
intValue
).
assertEqual
(
data
);
expect
(
intValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -304,7 +304,7 @@ describe('KvStoreTest', function () {
...
@@ -304,7 +304,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -315,17 +315,16 @@ describe('KvStoreTest', function () {
...
@@ -315,17 +315,16 @@ describe('KvStoreTest', function () {
var
boolValue
=
false
;
var
boolValue
=
false
;
const
promise
=
kvStore
.
put
(
KEY_TEST_BOOLEAN_ELEMENT
+
'
002
'
,
boolValue
);
const
promise
=
kvStore
.
put
(
KEY_TEST_BOOLEAN_ELEMENT
+
'
002
'
,
boolValue
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_BOOLEAN_ELEMENT
+
'
002
'
);
const
promise1
=
kvStore
.
get
(
KEY_TEST_BOOLEAN_ELEMENT
+
'
002
'
);
promise1
.
then
((
data
)
=>
{
promise1
.
then
((
data
)
=>
{
expect
(
boolValue
).
assertEqual
(
data
);
expect
(
boolValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
done
();
done
();
})
})
...
@@ -336,7 +335,7 @@ describe('KvStoreTest', function () {
...
@@ -336,7 +335,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -348,17 +347,16 @@ describe('KvStoreTest', function () {
...
@@ -348,17 +347,16 @@ describe('KvStoreTest', function () {
var
floatValue
=
123456.654321
;
var
floatValue
=
123456.654321
;
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
,
floatValue
);
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
,
floatValue
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
);
const
promise1
=
kvStore
.
get
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
);
promise1
.
then
((
data
)
=>
{
promise1
.
then
((
data
)
=>
{
expect
(
floatValue
).
assertEqual
(
data
);
expect
(
floatValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -370,17 +368,16 @@ describe('KvStoreTest', function () {
...
@@ -370,17 +368,16 @@ describe('KvStoreTest', function () {
var
floatValue
=
123456.0
;
var
floatValue
=
123456.0
;
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
003
'
,
floatValue
);
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
003
'
,
floatValue
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_FLOAT_ELEMENT
+
'
003
'
);
const
promise1
=
kvStore
.
get
(
KEY_TEST_FLOAT_ELEMENT
+
'
003
'
);
promise1
.
then
((
data
)
=>
{
promise1
.
then
((
data
)
=>
{
expect
(
floatValue
).
assertEqual
(
data
);
expect
(
floatValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -392,17 +389,16 @@ describe('KvStoreTest', function () {
...
@@ -392,17 +389,16 @@ describe('KvStoreTest', function () {
var
floatValue
=
123456.00
;
var
floatValue
=
123456.00
;
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
004
'
,
floatValue
);
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
004
'
,
floatValue
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
get
(
KEY_TEST_FLOAT_ELEMENT
+
'
004
'
);
const
promise1
=
kvStore
.
get
(
KEY_TEST_FLOAT_ELEMENT
+
'
004
'
);
promise1
.
then
((
data
)
=>
{
promise1
.
then
((
data
)
=>
{
expect
(
floatValue
).
assertEqual
(
data
);
expect
(
floatValue
).
assertEqual
(
data
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -414,16 +410,15 @@ describe('KvStoreTest', function () {
...
@@ -414,16 +410,15 @@ describe('KvStoreTest', function () {
var
str
=
'
this is a test string
'
;
var
str
=
'
this is a test string
'
;
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
,
str
);
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
,
str
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
const
promise1
=
kvStore
.
delete
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
);
promise1
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
const
promise1
=
kvStore
.
delete
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
);
promise1
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -438,17 +433,15 @@ describe('KvStoreTest', function () {
...
@@ -438,17 +433,15 @@ describe('KvStoreTest', function () {
}
}
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
,
str
);
const
promise
=
kvStore
.
put
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
,
str
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
const
promise1
=
kvStore
.
delete
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
);
promise1
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
const
promise1
=
kvStore
.
delete
(
KEY_TEST_STRING_ELEMENT
+
'
003
'
);
promise1
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -462,7 +455,7 @@ describe('KvStoreTest', function () {
...
@@ -462,7 +455,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -476,7 +469,7 @@ describe('KvStoreTest', function () {
...
@@ -476,7 +469,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -490,7 +483,7 @@ describe('KvStoreTest', function () {
...
@@ -490,7 +483,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -501,22 +494,15 @@ describe('KvStoreTest', function () {
...
@@ -501,22 +494,15 @@ describe('KvStoreTest', function () {
try
{
try
{
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
,
VALUE_TEST_FLOAT_ELEMENT
);
const
promise
=
kvStore
.
put
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
,
VALUE_TEST_FLOAT_ELEMENT
);
promise
.
then
((
data
)
=>
{
promise
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
promise
;
const
promise1
=
kvStore
.
delete
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
);
const
promise1
=
kvStore
.
delete
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
);
promise1
.
then
((
data
)
=>
{
promise1
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise1
;
const
promise2
=
kvStore
.
delete
(
KEY_TEST_FLOAT_ELEMENT
+
'
002
'
);
promise2
.
then
((
data
)
=>
{
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise2
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -530,7 +516,7 @@ describe('KvStoreTest', function () {
...
@@ -530,7 +516,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
)
;
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -548,8 +534,7 @@ describe('KvStoreTest', function () {
...
@@ -548,8 +534,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
);
await
(
3000
);
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -567,8 +552,7 @@ describe('KvStoreTest', function () {
...
@@ -567,8 +552,7 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
);
await
(
3000
);
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
@@ -586,8 +570,67 @@ describe('KvStoreTest', function () {
...
@@ -586,8 +570,67 @@ describe('KvStoreTest', function () {
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
});
});
await
promise
;
await
sleep
(
3000
);
await
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testOnSyncComplete001
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
syncComplete
'
,
function
(
data
)
{
expect
(
true
).
assertEqual
(
data
!=
null
);
});
const
promise
=
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync001
'
,
VALUE_TEST_SYNC_ELEMENT
);
promise
.
then
((
data
)
=>
{
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
PULL_ONLY
;
kvStore
.
sync
(
devices
,
mode
,
10
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testOnSyncComplete002
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
syncComplete
'
,
function
(
data
)
{
expect
(
true
).
assertEqual
(
data
!=
null
);
});
const
promise
=
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync001
'
,
VALUE_TEST_SYNC_ELEMENT
);
promise
.
then
((
data
)
=>
{
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
PUSH_ONLY
;
kvStore
.
sync
(
devices
,
mode
,
10
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
}
done
();
})
it
(
'
testOnSyncComplete003
'
,
0
,
async
function
(
done
)
{
try
{
kvStore
.
on
(
'
syncComplete
'
,
function
(
data
)
{
expect
(
true
).
assertEqual
(
data
!=
null
);
});
const
promise
=
kvStore
.
put
(
KEY_TEST_SYNC_ELEMENT
+
'
testSync001
'
,
VALUE_TEST_SYNC_ELEMENT
);
promise
.
then
((
data
)
=>
{
var
devices
=
[
'
A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB
'
];
var
mode
=
PUSH_PULL
;
kvStore
.
sync
(
devices
,
mode
,
10
);
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
});
await
sleep
(
3000
);
}
catch
(
e
)
{
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录