@wmfs/tymly-schedule-plugin 1.0.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.version +1 -1
  2. package/CHANGELOG.md +49 -0
  3. package/lib/blueprints/schedule-blueprint/card-templates/create-scheduled-task.json +97 -0
  4. package/lib/blueprints/schedule-blueprint/card-templates/view-all-scheduled-tasks.json +36 -0
  5. package/lib/blueprints/schedule-blueprint/card-templates/view-scheduled-task.json +148 -0
  6. package/lib/blueprints/schedule-blueprint/categories/schedule.json +8 -0
  7. package/lib/blueprints/schedule-blueprint/functions/generate-key.js +16 -0
  8. package/lib/blueprints/schedule-blueprint/functions/get-available-state-machines.js +18 -0
  9. package/lib/blueprints/schedule-blueprint/models/task.json +0 -14
  10. package/lib/blueprints/schedule-blueprint/state-machines/create-scheduled-task.json +66 -0
  11. package/lib/blueprints/schedule-blueprint/state-machines/modify-scheduled-task.json +74 -0
  12. package/lib/blueprints/schedule-blueprint/state-machines/start-task.json +36 -0
  13. package/lib/blueprints/schedule-blueprint/state-machines/stop-task.json +36 -0
  14. package/lib/blueprints/schedule-blueprint/state-machines/view-all-scheduled-tasks.json +69 -0
  15. package/lib/blueprints/schedule-blueprint/state-machines/view-scheduled-task.json +46 -0
  16. package/lib/blueprints/schedule-blueprint/template-roles/schedule-admin.json +4 -0
  17. package/lib/components/services/schedule/index.js +82 -24
  18. package/lib/components/services/schedule/utils/datetime-to-rule.js +1 -1
  19. package/lib/components/state-resources/create-scheduled-task/doc/example.json +8 -0
  20. package/lib/components/state-resources/create-scheduled-task/doc/index.js +4 -0
  21. package/lib/components/state-resources/create-scheduled-task/index.js +55 -0
  22. package/lib/components/state-resources/find-scheduled-executions/doc/example.json +8 -0
  23. package/lib/components/state-resources/find-scheduled-executions/doc/index.js +4 -0
  24. package/lib/components/state-resources/find-scheduled-executions/index.js +12 -0
  25. package/lib/components/state-resources/start-scheduled-task/doc/example.json +8 -0
  26. package/lib/components/state-resources/start-scheduled-task/doc/index.js +4 -0
  27. package/lib/components/state-resources/start-scheduled-task/index.js +12 -0
  28. package/lib/components/state-resources/stop-scheduled-task/doc/example.json +8 -0
  29. package/lib/components/state-resources/stop-scheduled-task/doc/index.js +4 -0
  30. package/lib/components/state-resources/stop-scheduled-task/index.js +12 -0
  31. package/lib/components/state-resources/update-scheduled-state-machine-config/doc/example.json +12 -0
  32. package/lib/components/state-resources/update-scheduled-state-machine-config/doc/index.js +4 -0
  33. package/lib/components/state-resources/update-scheduled-state-machine-config/index.js +35 -0
  34. package/lib/components/state-resources/update-scheduled-task/doc/example.json +13 -0
  35. package/lib/components/state-resources/update-scheduled-task/doc/index.js +4 -0
  36. package/lib/components/state-resources/update-scheduled-task/index.js +26 -0
  37. package/package.json +5 -6
  38. package/plugin.json +1 -1
  39. package/test/rule-to-datetime-tests.js +2 -2
  40. package/test/schedule-tests.js +17 -14
@@ -0,0 +1,69 @@
1
+ {
2
+ "Comment": "View Scheduled State Machines",
3
+ "name": "View Scheduled State Machines",
4
+ "version": "1.0",
5
+ "categories": [
6
+ "schedule"
7
+ ],
8
+ "instigators": [
9
+ "user"
10
+ ],
11
+ "instigatorGroup": "app",
12
+ "StartAt": "FindTasks",
13
+ "States": {
14
+ "FindTasks": {
15
+ "Type": "Task",
16
+ "Resource": "module:finding",
17
+ "ResourceConfig": {
18
+ "modelId": "schedule_task"
19
+ },
20
+ "ResultPath": "$.tasks",
21
+ "Next": "AddTaskLaunches"
22
+ },
23
+ "AddTaskLaunches": {
24
+ "Type": "Map",
25
+ "ItemsPath": "$.tasks",
26
+ "Iterator": {
27
+ "StartAt": "AddLaunches",
28
+ "States": {
29
+ "AddLaunches": {
30
+ "Type": "Pass",
31
+ "Parameters": {
32
+ "launches": [
33
+ {
34
+ "title": "View",
35
+ "stateMachineName": "schedule_viewScheduledTask",
36
+ "input": {
37
+ "key.$": "$.key"
38
+ }
39
+ }
40
+ ]
41
+ },
42
+ "ResultPath": "$",
43
+ "End": true
44
+ }
45
+ }
46
+ },
47
+ "ResultPath": "$.tasks",
48
+ "Next": "View"
49
+ },
50
+ "View": {
51
+ "Type": "Task",
52
+ "Resource": "module:awaitingHumanInput",
53
+ "ResourceConfig": {
54
+ "uiType": "app",
55
+ "uiName": "schedule_viewAllScheduledTasks",
56
+ "dataPath": "$"
57
+ },
58
+ "End": true
59
+ }
60
+ },
61
+ "restrictions": [
62
+ {
63
+ "roleId": "schedule_scheduleAdmin",
64
+ "allows": [
65
+ "*"
66
+ ]
67
+ }
68
+ ]
69
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "Comment": "View Scheduled State Machine",
3
+ "name": "View Scheduled State Machine",
4
+ "version": "1.0",
5
+ "categories": [
6
+ "schedule"
7
+ ],
8
+ "StartAt": "FindTask",
9
+ "States": {
10
+ "FindTask": {
11
+ "Type": "Task",
12
+ "InputPath": "$.key",
13
+ "Resource": "module:findingById",
14
+ "ResourceConfig": {
15
+ "modelId": "schedule_task"
16
+ },
17
+ "ResultPath": "$",
18
+ "Next": "FindExecutions"
19
+ },
20
+ "FindExecutions": {
21
+ "Type": "Task",
22
+ "InputPath": "$.key",
23
+ "Resource": "module:findScheduledExecutions",
24
+ "ResultPath": "$.executions",
25
+ "Next": "View"
26
+ },
27
+ "View": {
28
+ "Type": "Task",
29
+ "Resource": "module:awaitingHumanInput",
30
+ "ResourceConfig": {
31
+ "uiType": "app",
32
+ "uiName": "schedule_viewScheduledTask",
33
+ "dataPath": "$"
34
+ },
35
+ "End": true
36
+ }
37
+ },
38
+ "restrictions": [
39
+ {
40
+ "roleId": "schedule_scheduleAdmin",
41
+ "allows": [
42
+ "*"
43
+ ]
44
+ }
45
+ ]
46
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "label": "Schedule Admin",
3
+ "description": "Maintain scheduled state machines"
4
+ }
@@ -1,11 +1,17 @@
1
+ const INSTIGATING_CLIENT_DOMAIN = 'tymly-schedule-plugin'
2
+
1
3
  const nodeSchedule = require('node-schedule')
2
4
  const ruleToDatetime = require('./utils/rule-to-datetime')
3
5
  const datetimeToRule = require('./utils/datetime-to-rule')
6
+ const { v4: uuidv4 } = require('uuid')
4
7
 
5
8
  class CronService {
6
9
  async boot (options) {
7
10
  this.statebox = options.bootedServices.statebox
8
11
  this.taskModel = options.bootedServices.storage.models.schedule_task
12
+ this.executionModel = options.bootedServices.storage.models.tymly_execution
13
+
14
+ // todo: rename blueprint component to scheduled-tasks, blueprint component to have "type": "stateMachineName"
9
15
  this.scheduledTasks = await this.findTasks(options.blueprintComponents.stateMachineSchedules)
10
16
 
11
17
  for (const [key, task] of Object.entries(this.scheduledTasks)) {
@@ -49,16 +55,15 @@ class CronService {
49
55
  }
50
56
 
51
57
  // todo: allow window for start/end datetimes
52
-
53
58
  task.job = nodeSchedule.scheduleJob(
54
59
  jobOptions,
55
60
  () => {
56
61
  console.log(`Running scheduled state machine ${stateMachineName}`)
57
- const startedAt = new Date()
58
62
  const executionOptions = {
59
63
  instigatingClient: {
60
64
  appName: 'tymly',
61
- domain: 'tymly-schedule-plugin'
65
+ domain: INSTIGATING_CLIENT_DOMAIN,
66
+ scheduleKey: key
62
67
  },
63
68
  sendResponse
64
69
  }
@@ -66,7 +71,6 @@ class CronService {
66
71
  if (err) {
67
72
  console.log(`There was an error on execution of scheduled state machine ${stateMachineName}`)
68
73
  }
69
- await this.updateTaskOnExecution(key, executionDescription.executionName, startedAt)
70
74
  }
71
75
  this.statebox.startExecution(input, stateMachineName, executionOptions, cb)
72
76
  }
@@ -74,7 +78,7 @@ class CronService {
74
78
 
75
79
  this.scheduledTasks[key] = task
76
80
 
77
- return this.updateTaskStatus(key, 'STARTED')
81
+ return this.updateTaskStatus(key, task.job === null ? 'STOPPED' : 'STARTED')
78
82
  } // startTask
79
83
 
80
84
  stopTask (key) {
@@ -105,7 +109,7 @@ class CronService {
105
109
  setMissingPropertiesToNull: false
106
110
  }
107
111
  )
108
- }
112
+ } // updateTaskStatus
109
113
 
110
114
  stopTasks () {
111
115
  return Promise.all(
@@ -129,6 +133,11 @@ class CronService {
129
133
  continue
130
134
  }
131
135
 
136
+ const stateMachineOk = this.checkIfStateMachineExists(config.stateMachineName)
137
+ if (!stateMachineOk) {
138
+ continue
139
+ }
140
+
132
141
  // todo: recurrence rules?
133
142
 
134
143
  if (typeof config.interval === 'string') {
@@ -140,6 +149,10 @@ class CronService {
140
149
  config.interval = null
141
150
  }
142
151
 
152
+ config.input = typeof config.input === 'object'
153
+ ? config.input
154
+ : {}
155
+
143
156
  tasks[key] = config
144
157
 
145
158
  await this.persistTask(key, config)
@@ -158,35 +171,44 @@ class CronService {
158
171
  interval: config.interval,
159
172
  datetime: config.datetime,
160
173
  startOnBoot: config.startOnBoot,
161
- lastRanStart: null,
162
- lastRanEnd: null,
163
- lastRanExecutionName: null,
164
- totalRunCount: 0,
165
174
  status: null
166
175
  })
167
- }
176
+ } // persistTask
168
177
 
169
- async updateTaskOnExecution (key, executionName, startedAt) {
170
- const { totalRunCount } = await this.taskModel.findOne(
171
- {
172
- where: { key: { equals: key } },
173
- fields: ['totalRunCount']
174
- }
175
- )
178
+ checkIfStateMachineExists (stateMachineName) {
179
+ const [stateMachineOk, errStateMachineDesc] = this.statebox.checkIfStateMachineExists(stateMachineName)
180
+
181
+ if (!stateMachineOk) {
182
+ console.log('State machine error', errStateMachineDesc)
183
+ }
184
+
185
+ return stateMachineOk
186
+ } // checkIfStateMachineExists
187
+
188
+ async stopAndUpdateStateMachineConfig (key, stateMachineName, input) {
189
+ await this.stopTask(key)
190
+
191
+ const stateMachineOk = this.checkIfStateMachineExists(stateMachineName)
192
+ if (!stateMachineOk) {
193
+ return
194
+ }
195
+
196
+ this.scheduledTasks[key].stateMachineName = stateMachineName
197
+ this.scheduledTasks[key].input = typeof input === 'object'
198
+ ? input
199
+ : {}
176
200
 
177
201
  return this.taskModel.update(
178
202
  {
179
203
  key,
180
- lastRanStart: startedAt,
181
- lastRanEnd: new Date(),
182
- lastRanExecutionName: executionName,
183
- totalRunCount: totalRunCount + 1
204
+ stateMachineName: this.scheduledTasks[key].stateMachineName,
205
+ input: this.scheduledTasks[key].input
184
206
  },
185
207
  {
186
208
  setMissingPropertiesToNull: false
187
209
  }
188
210
  )
189
- }
211
+ } // stopAndUpdateStateMachineConfig
190
212
 
191
213
  async stopAndUpdateTaskSchedule (key, rule) {
192
214
  await this.stopTask(key)
@@ -212,7 +234,43 @@ class CronService {
212
234
  setMissingPropertiesToNull: false
213
235
  }
214
236
  )
215
- }
237
+ } // stopAndUpdateTaskSchedule
238
+
239
+ async findScheduledExecutions (key) {
240
+ const executions = await this.executionModel.find({
241
+ fields: [
242
+ 'executionName',
243
+ 'executionOptions',
244
+ 'status',
245
+ 'created',
246
+ 'modified'
247
+ ],
248
+ where: {
249
+ stateMachineName: {
250
+ equals: this.scheduledTasks[key].stateMachineName
251
+ }
252
+ },
253
+ orderBy: ['-modified']
254
+ })
255
+
256
+ return executions.filter(({ executionOptions }) => {
257
+ executionOptions = typeof executionOptions === 'string'
258
+ ? JSON.parse(executionOptions)
259
+ : executionOptions
260
+
261
+ return executionOptions.instigatingClient.domain === INSTIGATING_CLIENT_DOMAIN &&
262
+ executionOptions.instigatingClient.scheduleKey === key
263
+ })
264
+ } // findScheduledExecutions
265
+
266
+ createScheduledTask (key, config = {}) {
267
+ if (key === null) {
268
+ console.log('no key, generating...')
269
+ key = uuidv4()
270
+ }
271
+ this.scheduledTasks[key] = config
272
+ return this.persistTask(key, config)
273
+ } // createScheduledTask
216
274
 
217
275
  async shutdown () {
218
276
  await nodeSchedule.gracefulShutdown()
@@ -7,7 +7,7 @@ module.exports = function (datetime) {
7
7
  year: datetime.getFullYear(),
8
8
  month: datetime.getMonth(),
9
9
  date: datetime.getDate(),
10
- hour: datetime.getHours(),
10
+ hour: datetime.getHours() - 1,
11
11
  minute: datetime.getMinutes(),
12
12
  second: datetime.getSeconds()
13
13
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "CreateScheduledTask": {
3
+ "Type": "Task",
4
+ "InputPath": "$.key",
5
+ "Resource": "module:createScheduledTask",
6
+ "End": true
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ description: 'Create task',
3
+ example: require('./example.json')
4
+ }
@@ -0,0 +1,55 @@
1
+ // const datetimeToRule = require('../../services/schedule/utils/datetime-to-rule')
2
+
3
+ class CreateScheduledTask {
4
+ init (resourceConfig, env) {
5
+ this.services = env.bootedServices
6
+ }
7
+
8
+ async run (event, context) {
9
+ const {
10
+ key,
11
+ stateMachineName,
12
+ scheduleType,
13
+ datetime,
14
+ interval
15
+ } = event
16
+
17
+ const stateMachineOk = this.services.schedule.checkIfStateMachineExists(stateMachineName)
18
+ if (!stateMachineOk) {
19
+ return context.sendTaskSuccess()
20
+ }
21
+
22
+ let input = typeof event.input === 'object'
23
+ ? event.input
24
+ : {}
25
+
26
+ if (typeof event.input === 'string') {
27
+ try {
28
+ input = JSON.parse(event.input)
29
+ } catch (err) {
30
+ console.log('Issue with input', event.input)
31
+ }
32
+ }
33
+
34
+ // const rule = scheduleType === 'interval'
35
+ // ? interval
36
+ // : datetimeToRule(new Date(datetime))
37
+
38
+ const config = {
39
+ stateMachineName,
40
+ input,
41
+ sendResponse: 'COMPLETE',
42
+ scheduleType,
43
+ interval,
44
+ datetime,
45
+ startOnBoot: false // todo
46
+ }
47
+
48
+ await this.services.schedule.createScheduledTask(key, config)
49
+ // await this.services.schedule.stopAndUpdateTaskSchedule(key, rule)
50
+ // await this.services.schedule.stopAndUpdateStateMachineConfig(key, stateMachineName, input)
51
+ return context.sendTaskSuccess(key)
52
+ }
53
+ }
54
+
55
+ module.exports = CreateScheduledTask
@@ -0,0 +1,8 @@
1
+ {
2
+ "FindScheduledExecutions": {
3
+ "Type": "Task",
4
+ "InputPath": "$.key",
5
+ "Resource": "module:findScheduledExecutions",
6
+ "End": true
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ description: 'Find scheduled executions',
3
+ example: require('./example.json')
4
+ }
@@ -0,0 +1,12 @@
1
+ class FindScheduledExecutions {
2
+ init (resourceConfig, env) {
3
+ this.services = env.bootedServices
4
+ }
5
+
6
+ async run (key, context) {
7
+ const executions = await this.services.schedule.findScheduledExecutions(key)
8
+ return context.sendTaskSuccess(executions)
9
+ }
10
+ }
11
+
12
+ module.exports = FindScheduledExecutions
@@ -0,0 +1,8 @@
1
+ {
2
+ "StartScheduledTask": {
3
+ "Type": "Task",
4
+ "InputPath": "$.key",
5
+ "Resource": "module:startScheduledTask",
6
+ "End": true
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ description: 'Start task',
3
+ example: require('./example.json')
4
+ }
@@ -0,0 +1,12 @@
1
+ class StartScheduledTask {
2
+ init (resourceConfig, env) {
3
+ this.services = env.bootedServices
4
+ }
5
+
6
+ async run (key, context) {
7
+ await this.services.schedule.startTask(key)
8
+ return context.sendTaskSuccess()
9
+ }
10
+ }
11
+
12
+ module.exports = StartScheduledTask
@@ -0,0 +1,8 @@
1
+ {
2
+ "StopScheduledTask": {
3
+ "Type": "Task",
4
+ "InputPath": "$.key",
5
+ "Resource": "module:stopScheduledTask",
6
+ "End": true
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ description: 'Stop task',
3
+ example: require('./example.json')
4
+ }
@@ -0,0 +1,12 @@
1
+ class StopScheduledTask {
2
+ init (resourceConfig, env) {
3
+ this.services = env.bootedServices
4
+ }
5
+
6
+ async run (key, context) {
7
+ await this.services.schedule.stopTask(key)
8
+ return context.sendTaskSuccess()
9
+ }
10
+ }
11
+
12
+ module.exports = StopScheduledTask
@@ -0,0 +1,12 @@
1
+ {
2
+ "UpdateScheduledStateMachineConfig": {
3
+ "Type": "Task",
4
+ "Parameters": {
5
+ "key.$": "$.key",
6
+ "stateMachineName.$": "$.stateMachineName",
7
+ "input.$": "$.input"
8
+ },
9
+ "Resource": "module:updateScheduledStateMachineConfig",
10
+ "End": true
11
+ }
12
+ }
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ description: 'Update state machine config',
3
+ example: require('./example.json')
4
+ }
@@ -0,0 +1,35 @@
1
+ class UpdateScheduledStateMachineConfig {
2
+ init (resourceConfig, env) {
3
+ this.services = env.bootedServices
4
+ }
5
+
6
+ async run (event, context) {
7
+ const {
8
+ key,
9
+ stateMachineName
10
+ } = event
11
+
12
+ const stateMachineOk = this.services.schedule.checkIfStateMachineExists(stateMachineName)
13
+ if (!stateMachineOk) {
14
+ return context.sendTaskSuccess()
15
+ }
16
+
17
+ let input = typeof event.input === 'object'
18
+ ? event.input
19
+ : {}
20
+
21
+ if (typeof event.input === 'string') {
22
+ try {
23
+ input = JSON.parse(event.input)
24
+ } catch (err) {
25
+ console.log('Issue with input', event.input)
26
+ }
27
+ }
28
+
29
+ await this.services.schedule.stopAndUpdateStateMachineConfig(key, stateMachineName, input)
30
+
31
+ return context.sendTaskSuccess()
32
+ }
33
+ }
34
+
35
+ module.exports = UpdateScheduledStateMachineConfig
@@ -0,0 +1,13 @@
1
+ {
2
+ "UpdateScheduledTask": {
3
+ "Type": "Task",
4
+ "Parameters": {
5
+ "key.$": "$.key",
6
+ "scheduleType.$": "$.scheduleType",
7
+ "datetime.$": "$.datetime",
8
+ "interval.$": "$.interval"
9
+ },
10
+ "Resource": "module:updateScheduledTask",
11
+ "End": true
12
+ }
13
+ }
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ description: 'Update task',
3
+ example: require('./example.json')
4
+ }
@@ -0,0 +1,26 @@
1
+ const datetimeToRule = require('../../services/schedule/utils/datetime-to-rule')
2
+
3
+ class UpdateScheduledTask {
4
+ init (resourceConfig, env) {
5
+ this.services = env.bootedServices
6
+ }
7
+
8
+ async run (event, context) {
9
+ const {
10
+ key,
11
+ scheduleType,
12
+ datetime,
13
+ interval
14
+ } = event
15
+
16
+ const rule = scheduleType === 'interval'
17
+ ? interval
18
+ : datetimeToRule(new Date(datetime))
19
+
20
+ await this.services.schedule.stopAndUpdateTaskSchedule(key, rule)
21
+
22
+ return context.sendTaskSuccess()
23
+ }
24
+ }
25
+
26
+ module.exports = UpdateScheduledTask
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wmfs/tymly-schedule-plugin",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "Provides state machine scheduling for the Tymly framework",
5
5
  "homepage": "https://github.com/wmfs/tymly-schedule-plugin#readme",
6
6
  "author": "West Midlands Fire Service",
@@ -22,14 +22,16 @@
22
22
  },
23
23
  "main": "./lib/index.js",
24
24
  "dependencies": {
25
- "node-schedule": "2.1.0"
25
+ "node-schedule": "2.1.0",
26
+ "uuid": "^8.3.2"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@semantic-release/changelog": "6.0.1",
29
30
  "@semantic-release/exec": "6.0.3",
30
31
  "@semantic-release/git": "10.0.1",
31
32
  "@wmfs/tymly": "1.235.1",
32
- "@wmfs/tymly-pg-plugin": "1.268.0",
33
+ "@wmfs/tymly-pg-plugin": "1.268.1",
34
+ "@wmfs/tymly-test-helpers": "1.17.0",
33
35
  "chai": "4.3.6",
34
36
  "codecov": "3.8.3",
35
37
  "conventional-changelog-metahub": "4.0.1",
@@ -50,9 +52,6 @@
50
52
  "config": {
51
53
  "commitizen": {
52
54
  "path": "cz-conventional-changelog"
53
- },
54
- "tymly": {
55
- "sync": false
56
55
  }
57
56
  },
58
57
  "publishConfig": {
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "schedule-plugin",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "label": "Tymly Schedule Plugin",
5
5
  "author": "WMFS",
6
6
  "organisation": "West Midlands Fire Service",
@@ -81,7 +81,7 @@ describe('Datetime to rule tests', function () {
81
81
  expect(rule.year).to.eql(now.getFullYear())
82
82
  expect(rule.month).to.eql(now.getMonth())
83
83
  expect(rule.date).to.eql(now.getDate())
84
- expect(rule.hour).to.eql(now.getHours())
84
+ expect(rule.hour).to.eql(now.getHours() - 1)
85
85
  expect(rule.minute).to.eql(now.getMinutes())
86
86
  expect(rule.second).to.eql(now.getSeconds())
87
87
  })
@@ -96,7 +96,7 @@ describe('Datetime to rule tests', function () {
96
96
  expect(rule.year).to.eql(year)
97
97
  expect(rule.month).to.eql(datetime.getMonth())
98
98
  expect(rule.date).to.eql(datetime.getDate())
99
- expect(rule.hour).to.eql(datetime.getHours())
99
+ expect(rule.hour).to.eql(datetime.getHours() - 1)
100
100
  expect(rule.minute).to.eql(datetime.getMinutes())
101
101
  expect(rule.second).to.eql(datetime.getSeconds())
102
102
  })