From 6f52408e7bf79730df9eb7b487dcacf468e409e1 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Wed, 2 Dec 2020 04:10:15 +0300 Subject: test: Event model --- test/event.model.test.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/event.model.test.ts (limited to 'test/event.model.test.ts') diff --git a/test/event.model.test.ts b/test/event.model.test.ts new file mode 100644 index 0000000..05afb7a --- /dev/null +++ b/test/event.model.test.ts @@ -0,0 +1,34 @@ +import { expect } from 'chai'; +import Model from './model'; + +describe('Event model', () => { + 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'); + }) +}); -- cgit v1.2.3