Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/rule.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ describe("Rule", () => {
});

describe("constructor()", () => {
it("can be initialized without anything", () => {
const rule = new Rule();
expect(rule.name).toBeUndefined();
})

it("can be initialized with priority, conditions, event, and name", () => {
const condition = {
all: [Object.assign({}, conditionBase)],
Expand Down
5 changes: 5 additions & 0 deletions test/types.test-d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ describe("type tests", () => {
const rule = new Rule(ruleProps);
const ruleFromString: Rule = new Rule(JSON.stringify(ruleProps));

it("name of rule is possibly undefined", () => {
const ruleWithoutInit = new Rule();
expectTypeOf<string | undefined>(ruleWithoutInit.name);
})

it("returns the engine when adding a rule", () => {
expectTypeOf<Engine>(engine.addRule(rule));
});
Expand Down
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ export interface RuleResult {
}

export class Rule implements RuleProperties {
constructor(ruleProps: RuleProperties | string);
name: string;
constructor(ruleProps?: RuleProperties | string);
name?: string;
conditions: TopLevelCondition;
event: Event;
priority: number;
Expand Down
Loading