aboutsummaryrefslogtreecommitdiff
path: root/test/event.model.test.ts
blob: 0ca31668a3e136541cd1d19d9f2014c75964dfed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { expect } from 'chai';
import Model from './model';
import connection from './utils/dbConnection';

describe('Event model', () => {
  after(async () => {
    connection.dropCollection('customevents');
  });

  it('Should assign status and nextRunAt on creation', async () => {
    const event = await Model.create({
      type: 'test',
      schedule: '* * * * *',
      context: {
        message: 'Hello, world!'
      },
    });
    expect(event.status).equal('notStarted');
    expect(event).to.have.property('nextRunAt');
  });

  describe('Methods', () => {
    it('log', async () => {
      const event = await Model.findOne();
      const log = await event?.log('Test message');
      expect(log).to.have.property('message').equal('Test message');
    });

    it('start');

    it('complete');

    it('fail');

    it('getLogs')

    it('computeNextRunAt');
  })
});