Skip to content

Commit

Permalink
feat: refactor highlighter
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangechen committed Jul 16, 2024
1 parent d929012 commit e7c2f8a
Show file tree
Hide file tree
Showing 14 changed files with 630 additions and 168 deletions.
2 changes: 1 addition & 1 deletion packages/chili-core/src/visual/visualShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IVisualObject } from "./visualObject";

export enum VisualState {
normal = 0,
highlight = 1,
highlighter = 1,
selected = 1 << 1,
}

Expand Down
20 changes: 10 additions & 10 deletions packages/chili-core/test/visual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ describe("visual test", () => {
let state = VisualState.normal;
expect(state).toBe(0);

state = VisualState.addState(state, VisualState.highlight);
state = VisualState.addState(state, VisualState.highlighter);
expect(state).toBe(1);
expect(VisualState.hasState(state, VisualState.highlight)).toBeTruthy();
expect(VisualState.hasState(state, VisualState.highlighter)).toBeTruthy();
expect(VisualState.hasState(state, VisualState.selected)).toBeFalsy();

state = VisualState.addState(state, VisualState.selected);
expect(state).toBe(3);
expect(VisualState.hasState(state, VisualState.highlight)).toBeTruthy();
expect(VisualState.hasState(state, VisualState.highlighter)).toBeTruthy();
expect(VisualState.hasState(state, VisualState.selected)).toBeTruthy();

state = VisualState.removeState(state, VisualState.highlight);
state = VisualState.removeState(state, VisualState.highlighter);
expect(state).toBe(2);
expect(VisualState.hasState(state, VisualState.highlight)).toBeFalsy();
expect(VisualState.hasState(state, VisualState.highlighter)).toBeFalsy();
expect(VisualState.hasState(state, VisualState.selected)).toBeTruthy();

state = VisualState.removeState(state, VisualState.selected);
expect(state).toBe(0);
expect(VisualState.hasState(state, VisualState.highlight)).toBeFalsy();
expect(VisualState.hasState(state, VisualState.highlighter)).toBeFalsy();
expect(VisualState.hasState(state, VisualState.selected)).toBeFalsy();

state = VisualState.highlight;
state = VisualState.highlighter;
state = VisualState.addState(state, VisualState.selected);
expect(state).toBe(3);
expect(VisualState.hasState(state, VisualState.highlight)).toBeTruthy();
expect(VisualState.hasState(state, VisualState.highlighter)).toBeTruthy();
expect(VisualState.hasState(state, VisualState.selected)).toBeTruthy();

state = VisualState.removeState(state, VisualState.highlight);
state = VisualState.removeState(state, VisualState.highlighter);
expect(state).toBe(2);
expect(VisualState.hasState(state, VisualState.highlight)).toBeFalsy();
expect(VisualState.hasState(state, VisualState.highlighter)).toBeFalsy();
expect(VisualState.hasState(state, VisualState.selected)).toBeTruthy();
});
});
Loading

0 comments on commit e7c2f8a

Please sign in to comment.