提交 1fc5354c 编写于 作者: Z zhangmaowen

<zhangmaowen@huawei.com>

Signed-off-by: Nzhangmaowen <zhangmaowen@huawei.com>
上级 73dbcff8
......@@ -14,8 +14,7 @@
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import dataRdb from '@ohos.data.rdb';
import dataAbility from '@ohos.data.dataability';
import featureAbility from '@ohos.ability.featureAbility';
import dataAbility from '@ohos.data.dataAbility';
const TAG = "[RDB_JSKITS _TEST]"
const CREATE_TABLE_ALL_DATA_TYPE_SQL = "CREATE TABLE IF NOT EXISTS AllDataType "
......@@ -31,14 +30,12 @@ const STORE_CONFIG = {
name: "Predicates.db",
}
var rdbStore = undefined;
var context = undefined;
var DOUBLE_MAX = 9223372036854775807;
describe('dataAbilityPredicatesTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
context = await featureAbility.getContext();
rdbStore = await dataRdb.getRdbStore(context, STORE_CONFIG, 1);
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_ALL_DATA_TYPE_SQL, null);
await buildAllDataType1();
await buildAllDataType2();
......@@ -56,7 +53,7 @@ describe('dataAbilityPredicatesTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await dataRdb.deleteRdbStore(context, "Predicates.db");
await dataRdb.deleteRdbStore("Predicates.db");
})
function resultSize(resultSet) {
......
......@@ -13,8 +13,7 @@
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
import dataRdb from '@ohos.data.rdb';
const TAG = "[RDB_JSKITS_TEST]"
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
......@@ -23,7 +22,6 @@ const STORE_CONFIG = {
name: "Delete.db",
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreDeleteTest', function () {
beforeAll(function () {
......@@ -32,8 +30,7 @@ describe('rdbStoreDeleteTest', function () {
beforeEach(async function () {
console.info(TAG + 'beforeEach')
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -41,7 +38,7 @@ describe('rdbStoreDeleteTest', function () {
console.info(TAG + 'afterEach')
await rdbStore.executeSql("DELETE FROM test");
rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "Delete.db");
await dataRdb.deleteRdbStore("Delete.db");
})
afterAll(async function () {
......@@ -86,7 +83,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
expect(3).assertEqual(ret)
......@@ -137,7 +134,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("name", "zhangsan")
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
......@@ -180,14 +177,14 @@ describe('rdbStoreDeleteTest', function () {
}
//删除前查询
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28)
let resultSet = await rdbStore.query(predicates)
expect(1).assertEqual(resultSet.rowCount)
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28)
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
......@@ -200,7 +197,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除后查询
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28)
let resultSet = await rdbStore.query(predicates)
expect(0).assertEqual(resultSet.rowCount)
......@@ -246,7 +243,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("aaa id", 1)
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
......@@ -297,7 +294,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("name", "lisi")
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
......@@ -349,7 +346,7 @@ describe('rdbStoreDeleteTest', function () {
}
//删除
{
let predicates = await new ohos_data_rdb.RdbPredicates("")
let predicates = await new dataRdb.RdbPredicates("")
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
console.log(TAG + "delete done: " + ret)
......
......@@ -14,8 +14,7 @@
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
import dataRdb from '@ohos.data.rdb';
const TAG = "[RDB_JSKITS_TEST]"
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
......@@ -25,13 +24,11 @@ const STORE_CONFIG = {
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreInsertTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -47,7 +44,7 @@ describe('rdbStoreInsertTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "InsertTest.db");
await dataRdb.deleteRdbStore("InsertTest.db");
})
console.log(TAG + "*************Unit Test Begin*************");
......@@ -88,7 +85,7 @@ describe('rdbStoreInsertTest', function () {
await rdbStore.insert("test", valueBucket)
}
let predicates = new ohos_data_rdb.RdbPredicates("test");
let predicates = new dataRdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan")
let resultSet = await rdbStore.query(predicates)
try {
......
......@@ -110,8 +110,8 @@ describe('storageTest', function () {
}
try {
perf.putSync("int", 3);
expect(null).assertFail();
} catch (e) {
expect(null).assertFail();
}
})
......
......@@ -50,7 +50,7 @@ describe('storageTest', function () {
* @tc.desc Constructor test
*/
it('testConstructor002', 0, function () {
expect(mPref).assertEqual('[object Object]');
expect(typeof mPref).assertEqual("object");
})
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册