test: rules
This commit is contained in:
parent
81acb44601
commit
6d27ac6777
1 changed files with 22 additions and 10 deletions
|
|
@ -1,14 +1,13 @@
|
|||
import { isRuleActive } from "./isRuleActive";
|
||||
|
||||
describe("isRuleActive", () => {
|
||||
it("should correctly evaluate combined contains and glob conditions", () => {
|
||||
const rule = {
|
||||
name: "My Rule",
|
||||
rule: "Do no harm",
|
||||
if: "${{ and(contains(current.model.model, 'claude-3-7-sonnet'), glob('*.tsx')) }}",
|
||||
};
|
||||
const rule = {
|
||||
name: "My Rule",
|
||||
rule: "Do no harm",
|
||||
if: "${{ and(contains(current.model.model, 'claude-3-7-sonnet') and glob('*.tsx')) }}",
|
||||
};
|
||||
|
||||
// Should be false when activePaths is empty
|
||||
it("should return false when activePaths is empty", () => {
|
||||
expect(
|
||||
isRuleActive({
|
||||
rule,
|
||||
|
|
@ -16,8 +15,9 @@ describe("isRuleActive", () => {
|
|||
currentModel: "claude-3-7-sonnet",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
// Should be false when no matching paths
|
||||
it("should return false when no matching paths exist", () => {
|
||||
expect(
|
||||
isRuleActive({
|
||||
rule,
|
||||
|
|
@ -25,8 +25,9 @@ describe("isRuleActive", () => {
|
|||
currentModel: "claude-3-7-sonnet",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
// Should be true when both conditions are met
|
||||
it("should return true when both conditions are met", () => {
|
||||
expect(
|
||||
isRuleActive({
|
||||
rule,
|
||||
|
|
@ -34,8 +35,9 @@ describe("isRuleActive", () => {
|
|||
currentModel: "claude-3-7-sonnet",
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
// Should be false when only glob matches
|
||||
it("should return false when only glob matches but model doesn't", () => {
|
||||
expect(
|
||||
isRuleActive({
|
||||
rule,
|
||||
|
|
@ -44,4 +46,14 @@ describe("isRuleActive", () => {
|
|||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false when model matches but glob doesn't", () => {
|
||||
expect(
|
||||
isRuleActive({
|
||||
rule,
|
||||
activePaths: ["Component.ts"],
|
||||
currentModel: "claude-3-7-sonnet",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue