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

<zhangmaowen@huawei.com>

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