Skip to content

Commit 602ca07

Browse files
committed
bumping coverage to 100%
1 parent 7344f44 commit 602ca07

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/Engine.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ class Engine {
77
this.rules = rules;
88
if (isDevelopment()) {
99
let conditions = rules.map(rule => rule.conditions);
10-
validatePredicates(conditions);
1110
if (schema !== undefined && schema !== null) {
1211
if (isObject(schema)) {
12+
validatePredicates(conditions);
1313
validateConditionFields(conditions, schema)
1414
} else {
1515
toError(`Expected valid schema object, but got - ${schema}`)

test/Engine.invalid.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ let schema = {
2828
};
2929

3030
test("ignore invalid rules if no schema provided", () => {
31-
expect(() => new Engine(invalidRules)).not.toBeUndefined();
31+
expect(() => new Engine(invalidRules)).not.toThrow();
3232
});
3333

34-
test("ignore invalid rules with invalid schema", () => {
35-
expect(() => new Engine({}, [])).toThrow();
36-
expect(() => new Engine({}, "schema")).toThrow();
34+
test("ignore empty rules with invalid schema", () => {
35+
expect(() => new Engine(invalidRules, [])).toThrow();
36+
expect(() => new Engine(invalidRules, "schema")).toThrow();
3737
});
3838

3939
test("initialize with invalid rules", () => {

test/validation.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ test("invalid field or", () => {
150150

151151
expect(() => predicatesFromRule(invalidFieldOr[0].firstName)).toThrow();
152152
expect(testInProd(() => predicatesFromRule(invalidFieldOr[0].firstName))).toEqual([]);
153-
expect(() => validate(invalidFieldOr, schema)).toThrow();
153+
expect(() => validatePredicates(invalidFieldOr, schema)).toThrow();
154154
});
155155

156156
test("invalid field NOT or", () => {
@@ -165,7 +165,7 @@ test("invalid field NOT or", () => {
165165
},
166166
]);
167167

168-
expect(() => validate(invalidFieldNotWithOr, schema)).toThrow();
168+
expect(() => validatePredicates(invalidFieldNotWithOr, schema)).toThrow();
169169
});
170170

171171
test("valid field or", () => {

0 commit comments

Comments
 (0)