Skip to content

Commit f5010e8

Browse files
test: use toHaveProperty 2nd param to simplify test
1 parent 992c52a commit f5010e8

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

tests/package.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,16 @@ describe('package', () => {
6565
}
6666

6767
// Strict configuration always includes all recommended rules.
68-
expect(plugin.configs.strict.rules).toHaveProperty(fullRuleName);
69-
// Not allowed to specify non-default options if rule only specifies a configuration name.
70-
expect(typeof plugin.configs.strict.rules[fullRuleName as keyof typeof plugin.configs.strict.rules]).toBe('string');
68+
// Not allowed to specify non-default options since rule only specifies a configuration name.
69+
expect(plugin.configs.strict.rules).toHaveProperty(fullRuleName, expect.any(String));
7170
} else {
7271
// Rule specifies non-default options for strict.
7372
if (rule.meta.docs.recommended.recommended) {
7473
expect(plugin.configs.recommended.rules).toHaveProperty(fullRuleName);
7574
} else {
7675
expect(plugin.configs.recommended.rules).not.toHaveProperty(fullRuleName);
7776
}
78-
expect(plugin.configs.strict.rules).toHaveProperty(fullRuleName);
79-
expect(plugin.configs.strict.rules[fullRuleName as keyof typeof plugin.configs.strict.rules]).toBeInstanceOf(Array);
80-
expect(plugin.configs.strict.rules[fullRuleName as keyof typeof plugin.configs.strict.rules][1]).toEqual(rule.meta.docs.recommended.strict[0]);
77+
expect(plugin.configs.strict.rules).toHaveProperty(fullRuleName, [expect.any(String), rule.meta.docs.recommended.strict[0]]);
8178
}
8279
});
8380
});

0 commit comments

Comments
 (0)