Skip to content

Commit 2a1ec93

Browse files
authored
Merge pull request #404 from emilefokkemanavara/fix/rule-type-rule-event
call Rule.ruleEvent by its correct name
2 parents 00061ac + 72d7b1a commit 2a1ec93

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/rule.js

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class Rule extends EventEmitter {
101101
this.ruleEvent = {
102102
type: event.type
103103
}
104+
this.event = this.ruleEvent
104105
if (event.params) this.ruleEvent.params = event.params
105106
return this
106107
}

test/rule.test.js

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe('Rule', () => {
3030
expect(rule.priority).to.eql(opts.priority)
3131
expect(rule.conditions).to.eql(opts.conditions)
3232
expect(rule.ruleEvent).to.eql(opts.event)
33+
expect(rule.event).to.eql(opts.event)
3334
expect(rule.name).to.eql(opts.name)
3435
})
3536

@@ -52,6 +53,7 @@ describe('Rule', () => {
5253
expect(rule.priority).to.eql(opts.priority)
5354
expect(rule.conditions).to.eql(opts.conditions)
5455
expect(rule.ruleEvent).to.eql(opts.event)
56+
expect(rule.event).to.eql(opts.event)
5557
expect(rule.name).to.eql(opts.name)
5658
})
5759
})
@@ -322,6 +324,7 @@ describe('Rule', () => {
322324
expect(hydratedRule.conditions).to.eql(rule.conditions)
323325
expect(hydratedRule.priority).to.eql(rule.priority)
324326
expect(hydratedRule.ruleEvent).to.eql(rule.ruleEvent)
327+
expect(hydratedRule.event).to.eql(rule.event)
325328
expect(hydratedRule.name).to.eql(rule.name)
326329
})
327330

@@ -333,6 +336,7 @@ describe('Rule', () => {
333336
expect(hydratedRule.conditions).to.eql(rule.conditions)
334337
expect(hydratedRule.priority).to.eql(rule.priority)
335338
expect(hydratedRule.ruleEvent).to.eql(rule.ruleEvent)
339+
expect(hydratedRule.event).to.eql(rule.event)
336340
expect(hydratedRule.name).to.eql(rule.name)
337341
})
338342
})

types/index.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ export class Rule implements RuleProperties {
175175
constructor(ruleProps: RuleProperties | string);
176176
name: string;
177177
conditions: TopLevelCondition;
178-
event: Event;
178+
/**
179+
* @deprecated Use {@link Rule.event} instead.
180+
*/
181+
ruleEvent: Event;
182+
event: Event
179183
priority: number;
180184
setConditions(conditions: TopLevelCondition): this;
181185
setEvent(event: Event): this;

0 commit comments

Comments
 (0)