1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/CliClient/tests/base-model.js

40 lines
1.2 KiB
JavaScript
Raw Normal View History

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();
});
});