Skip to content

Commit

Permalink
Merge pull request #404 from emilefokkemanavara/fix/rule-type-rule-event
Browse files Browse the repository at this point in the history
call Rule.ruleEvent by its correct name
  • Loading branch information
chris-pardy authored Dec 18, 2024
2 parents 00061ac + 72d7b1a commit 2a1ec93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class Rule extends EventEmitter {
this.ruleEvent = {
type: event.type
}
this.event = this.ruleEvent
if (event.params) this.ruleEvent.params = event.params
return this
}
Expand Down
4 changes: 4 additions & 0 deletions test/rule.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('Rule', () => {
expect(rule.priority).to.eql(opts.priority)
expect(rule.conditions).to.eql(opts.conditions)
expect(rule.ruleEvent).to.eql(opts.event)
expect(rule.event).to.eql(opts.event)
expect(rule.name).to.eql(opts.name)
})

Expand All @@ -52,6 +53,7 @@ describe('Rule', () => {
expect(rule.priority).to.eql(opts.priority)
expect(rule.conditions).to.eql(opts.conditions)
expect(rule.ruleEvent).to.eql(opts.event)
expect(rule.event).to.eql(opts.event)
expect(rule.name).to.eql(opts.name)
})
})
Expand Down Expand Up @@ -322,6 +324,7 @@ describe('Rule', () => {
expect(hydratedRule.conditions).to.eql(rule.conditions)
expect(hydratedRule.priority).to.eql(rule.priority)
expect(hydratedRule.ruleEvent).to.eql(rule.ruleEvent)
expect(hydratedRule.event).to.eql(rule.event)
expect(hydratedRule.name).to.eql(rule.name)
})

Expand All @@ -333,6 +336,7 @@ describe('Rule', () => {
expect(hydratedRule.conditions).to.eql(rule.conditions)
expect(hydratedRule.priority).to.eql(rule.priority)
expect(hydratedRule.ruleEvent).to.eql(rule.ruleEvent)
expect(hydratedRule.event).to.eql(rule.event)
expect(hydratedRule.name).to.eql(rule.name)
})
})
Expand Down
6 changes: 5 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ export class Rule implements RuleProperties {
constructor(ruleProps: RuleProperties | string);
name: string;
conditions: TopLevelCondition;
event: Event;
/**
* @deprecated Use {@link Rule.event} instead.
*/
ruleEvent: Event;
event: Event
priority: number;
setConditions(conditions: TopLevelCondition): this;
setEvent(event: Event): this;
Expand Down

0 comments on commit 2a1ec93

Please sign in to comment.