This commit fixes an issue where the check state of categories was lost when toggling between card and tree views. This is solved by immediately emitting node state changes for all nodes. This ensures consistent view transitions without any loss of node state information. Furthermore, this commit includes added unit tests for the modified code sections.
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { TreeInputNodeData } from '@/presentation/components/Scripts/View/Tree/TreeView/Bindings/TreeInputNodeData';
|
|
import { TreeNode } from '@/presentation/components/Scripts/View/Tree/TreeView/Node/TreeNode';
|
|
import { parseTreeInput } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/NodeCollection/TreeInputParser';
|
|
import { TreeNodeStub } from './TreeNodeStub';
|
|
|
|
interface StubScenario {
|
|
readonly given: readonly TreeInputNodeData[],
|
|
readonly result: TreeNode[],
|
|
}
|
|
|
|
export function createTreeNodeParserStub() {
|
|
const scenarios = new Array<StubScenario>();
|
|
function registerScenario(scenario: StubScenario) {
|
|
scenarios.push(scenario);
|
|
}
|
|
const parseTreeInputStub: typeof parseTreeInput = (
|
|
data: readonly TreeInputNodeData[],
|
|
): TreeNode[] => {
|
|
const result = scenarios.find((scenario) => scenario.given === data);
|
|
if (result !== undefined) {
|
|
return result.result;
|
|
}
|
|
return data.map(() => new TreeNodeStub()
|
|
.withId(`[${createTreeNodeParserStub.name}] parsed-node-stub`));
|
|
};
|
|
return {
|
|
registerScenario,
|
|
parseTreeInputStub,
|
|
};
|
|
}
|