|
|
|
@ -175,6 +175,15 @@ describe('Database', async function() {
|
|
|
|
|
await db_api.removeRecord('test', {test_update: 'test'});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Remove property from record', async function() {
|
|
|
|
|
await db_api.insertRecordIntoTable('test', {test_keep: 'test', test_remove: 'test'});
|
|
|
|
|
await db_api.removePropertyFromRecord('test', {test_keep: 'test'}, {test_remove: true});
|
|
|
|
|
const updated_record = await db_api.getRecord('test', {test_keep: 'test'});
|
|
|
|
|
assert(updated_record['test_keep']);
|
|
|
|
|
assert(!updated_record['test_remove']);
|
|
|
|
|
await db_api.removeRecord('test', {test_keep: 'test'});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Remove record', async function() {
|
|
|
|
|
await db_api.insertRecordIntoTable('test', {test_remove: 'test'});
|
|
|
|
|
const delete_succeeded = await db_api.removeRecord('test', {test_remove: 'test'});
|
|
|
|
@ -699,4 +708,24 @@ describe('Utils', async function() {
|
|
|
|
|
const stripped_obj = utils.stripPropertiesFromObject(test_obj, ['test1', 'test3']);
|
|
|
|
|
assert(!stripped_obj['test1'] && stripped_obj['test2'] && !stripped_obj['test3'])
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('Convert flat object to nested object', async function() {
|
|
|
|
|
// No modfication
|
|
|
|
|
const flat_obj0 = {'test1': {'test_sub': true}, 'test2': {test_sub: true}};
|
|
|
|
|
const nested_obj0 = utils.convertFlatObjectToNestedObject(flat_obj0);
|
|
|
|
|
assert(nested_obj0['test1'] && nested_obj0['test1']['test_sub']);
|
|
|
|
|
assert(nested_obj0['test2'] && nested_obj0['test2']['test_sub']);
|
|
|
|
|
|
|
|
|
|
// Standard setup
|
|
|
|
|
const flat_obj1 = {'test1.test_sub': true, 'test2.test_sub': true};
|
|
|
|
|
const nested_obj1 = utils.convertFlatObjectToNestedObject(flat_obj1);
|
|
|
|
|
assert(nested_obj1['test1'] && nested_obj1['test1']['test_sub']);
|
|
|
|
|
assert(nested_obj1['test2'] && nested_obj1['test2']['test_sub']);
|
|
|
|
|
|
|
|
|
|
// Nested branches
|
|
|
|
|
const flat_obj2 = {'test1.test_sub': true, 'test1.test2.test_sub': true};
|
|
|
|
|
const nested_obj2 = utils.convertFlatObjectToNestedObject(flat_obj2);
|
|
|
|
|
assert(nested_obj2['test1'] && nested_obj2['test1']['test_sub']);
|
|
|
|
|
assert(nested_obj2['test1'] && nested_obj2['test1']['test2'] && nested_obj2['test1']['test2']['test_sub']);
|
|
|
|
|
});
|
|
|
|
|
});
|