bito-code-review[bot] commented on PR #43732:
URL: https://github.com/apache/superset/pull/43732#issuecomment-5497713913

   <!-- Bito Reply -->
   To add a Jest regression test for the layout logic in `Partition.ts`, you 
can create a test case that constructs a tree with uneven branching and 
verifies that each node's `x` and `dx` values remain within the bounds of its 
parent's `[x, x + dx]` band. Below is an example of how to structure this test 
in `superset-frontend/plugins/plugin-chart-partition/test/Partition.test.ts` 
(or a similar test file):
   
   ```typescript
   import { init } from '../src/Partition';
   
   test('nodes stay within parent band in uneven tree', () => {
     const root = { depth: 0, height: 2, x: 0, dx: 1, sum: 10, children: [
       { depth: 1, weight: 5, parent: null }, // Will be set by init
       { depth: 1, weight: 5, parent: null }
     ] } as any;
     // Mock root.each and other necessary methods if needed
     const nodes = init(root);
     nodes.forEach(n => {
       if (n.parent) {
         expect(n.x).toBeGreaterThanOrEqual(n.parent.x);
         expect(n.x + n.dx).toBeLessThanOrEqual(n.parent.x + n.parent.dx);
       }
     });
   });
   ```
   
   Ensure you mock the `PartitionNode` structure appropriately to match the 
expectations of the `init` function.
   
   **superset-frontend/plugins/plugin-chart-partition/test/Partition.test.ts**
   ```
   test('nodes stay within parent band in uneven tree', () => {
     const root = { depth: 0, height: 2, x: 0, dx: 1, sum: 10, children: [
       { depth: 1, weight: 5, parent: null },
       { depth: 1, weight: 5, parent: null }
     ] } as any;
     const nodes = init(root);
     nodes.forEach(n => {
       if (n.parent) {
         expect(n.x).toBeGreaterThanOrEqual(n.parent.x);
         expect(n.x + n.dx).toBeLessThanOrEqual(n.parent.x + n.parent.dx);
       }
     });
   });
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to