haifa-reminder/node_modules/node-cron/test/storage-test.js

26 lines
No EOL
828 B
JavaScript

const { assert } = require('chai');
const storage = require('../src/storage');
describe('storage', () => {
it('should store a task', () => {
global.scheduledTasks = new Map();
storage.save({});
assert.lengthOf(global.scheduledTasks, 1);
});
it('should get all tasks', () => {
global.scheduledTasks = new Map();
global.scheduledTasks.set(0, {});
assert.lengthOf(storage.getTasks(), 1);
});
describe('on import', () => {
it('should keep stored items across imports', () => {
delete require.cache[require.resolve('../src/storage')];
global.scheduledTasks = new Map();
storage.save({});
let storage2 = require('../src/storage');
assert.lengthOf(storage2.getTasks(), 1);
});
});
});