2017-11-03 02:09:34 +02:00
|
|
|
const { time } = require('lib/time-utils.js');
|
|
|
|
const { setupDatabase, setupDatabaseAndSynchronizer, db, synchronizer, fileApi, sleep, clearDatabase, switchClient } = require('test-utils.js');
|
|
|
|
const { Folder } = require('lib/models/folder.js');
|
|
|
|
const { Note } = require('lib/models/note.js');
|
|
|
|
const { Setting } = require('lib/models/setting.js');
|
|
|
|
const { BaseItem } = require('lib/models/base-item.js');
|
|
|
|
const { BaseModel } = require('lib/base-model.js');
|
2017-06-20 00:18:24 +02:00
|
|
|
|
|
|
|
process.on('unhandledRejection', (reason, p) => {
|
|
|
|
console.error('Unhandled promise rejection at: Promise', p, 'reason:', reason);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('BaseItem', function() {
|
|
|
|
|
|
|
|
beforeEach( async (done) => {
|
|
|
|
await setupDatabaseAndSynchronizer(1);
|
|
|
|
switchClient(1);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should create a deleted_items record', async (done) => {
|
2017-06-25 17:17:40 +02:00
|
|
|
let folder1 = await Folder.save({ title: 'folder1' });
|
|
|
|
let folder2 = await Folder.save({ title: 'folder2' });
|
2017-06-20 00:18:24 +02:00
|
|
|
|
2017-06-25 17:17:40 +02:00
|
|
|
await Folder.delete(folder1.id);
|
2017-06-20 00:18:24 +02:00
|
|
|
|
2017-07-03 21:50:45 +02:00
|
|
|
let items = await BaseItem.deletedItems();
|
2017-06-20 00:18:24 +02:00
|
|
|
|
|
|
|
expect(items.length).toBe(1);
|
2017-06-25 17:17:40 +02:00
|
|
|
expect(items[0].item_id).toBe(folder1.id);
|
|
|
|
expect(items[0].item_type).toBe(folder1.type_);
|
2017-06-20 00:18:24 +02:00
|
|
|
|
|
|
|
let folders = await Folder.all();
|
|
|
|
|
2017-06-25 17:17:40 +02:00
|
|
|
expect(folders.length).toBe(1);
|
2017-06-20 00:18:24 +02:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|