|
| 1 | +import { generatePath } from '../path'; |
| 2 | + |
| 3 | +describe('Masonry: Brick > Path Generation', () => { |
| 4 | + const testCases = [ |
| 5 | + { |
| 6 | + name: 'Type1 – No Args, Label Present', |
| 7 | + input: { |
| 8 | + type: 'type1', |
| 9 | + strokeWidth: 2, |
| 10 | + scaleFactor: 1, |
| 11 | + bBoxLabel: { w: 20, h: 35 }, |
| 12 | + bBoxArgs: [{ w: 40, h: 35 }], |
| 13 | + hasNotchAbove: true, |
| 14 | + hasNotchBelow: true, |
| 15 | + }, |
| 16 | + }, |
| 17 | + { |
| 18 | + name: 'Type1 – No Args, Label = 0', |
| 19 | + input: { |
| 20 | + type: 'type1', |
| 21 | + strokeWidth: 2, |
| 22 | + scaleFactor: 1, |
| 23 | + bBoxLabel: { w: 100, h: 0 }, |
| 24 | + bBoxArgs: [], |
| 25 | + hasNotchAbove: true, |
| 26 | + hasNotchBelow: true, |
| 27 | + }, |
| 28 | + }, |
| 29 | + { |
| 30 | + name: 'Type2 - Label > Sum(args), 1 Arg', |
| 31 | + input: { |
| 32 | + type: 'type2', |
| 33 | + strokeWidth: 2, |
| 34 | + scaleFactor: 1, |
| 35 | + bBoxLabel: { w: 150, h: 90 }, |
| 36 | + bBoxArgs: [{ w: 70, h: 45 }], |
| 37 | + }, |
| 38 | + }, |
| 39 | + { |
| 40 | + name: 'Type2 – Label < Sum(args), 2 Args', |
| 41 | + input: { |
| 42 | + type: 'type2', |
| 43 | + strokeWidth: 2, |
| 44 | + scaleFactor: 1, |
| 45 | + bBoxLabel: { w: 60, h: 20 }, |
| 46 | + bBoxArgs: [ |
| 47 | + { w: 20, h: 40 }, |
| 48 | + { w: 20, h: 40 }, |
| 49 | + ], |
| 50 | + }, |
| 51 | + }, |
| 52 | + { |
| 53 | + name: 'Type2 – Label = Sum(args), 3 Args', |
| 54 | + input: { |
| 55 | + type: 'type2', |
| 56 | + strokeWidth: 2, |
| 57 | + scaleFactor: 1, |
| 58 | + bBoxLabel: { w: 120, h: 90 }, |
| 59 | + bBoxArgs: [ |
| 60 | + { w: 60, h: 30 }, |
| 61 | + { w: 70, h: 30 }, |
| 62 | + { w: 40, h: 60 }, |
| 63 | + ], |
| 64 | + }, |
| 65 | + }, |
| 66 | + { |
| 67 | + name: 'Type3 – Label > args, 2 nesting, secondaryLabel false', |
| 68 | + input: { |
| 69 | + type: 'type3', |
| 70 | + strokeWidth: 2, |
| 71 | + scaleFactor: 1, |
| 72 | + bBoxLabel: { w: 140, h: 50 }, |
| 73 | + bBoxArgs: [ |
| 74 | + { w: 50, h: 20 }, |
| 75 | + { w: 60, h: 15 }, |
| 76 | + ], |
| 77 | + hasNotchAbove: true, |
| 78 | + hasNotchBelow: false, |
| 79 | + bBoxNesting: [ |
| 80 | + { w: 80, h: 40 }, |
| 81 | + { w: 100, h: 30 }, |
| 82 | + ], |
| 83 | + secondaryLabel: false, |
| 84 | + }, |
| 85 | + }, |
| 86 | + { |
| 87 | + name: 'Type3 – Label < args, nesting empty, secondaryLabel true', |
| 88 | + input: { |
| 89 | + type: 'type3', |
| 90 | + strokeWidth: 2, |
| 91 | + scaleFactor: 1, |
| 92 | + bBoxLabel: { w: 100, h: 20 }, |
| 93 | + bBoxArgs: [ |
| 94 | + { w: 60, h: 40 }, |
| 95 | + { w: 60, h: 50 }, |
| 96 | + ], |
| 97 | + hasNotchAbove: false, |
| 98 | + hasNotchBelow: true, |
| 99 | + bBoxNesting: [], |
| 100 | + secondaryLabel: true, |
| 101 | + }, |
| 102 | + }, |
| 103 | + { |
| 104 | + name: 'Type3 – No label, 1 arg, 1 nesting, all minimal sizes', |
| 105 | + input: { |
| 106 | + type: 'type3', |
| 107 | + strokeWidth: 2, |
| 108 | + scaleFactor: 1, |
| 109 | + bBoxLabel: { w: 0, h: 0 }, |
| 110 | + bBoxArgs: [{ w: 0, h: 20 }], |
| 111 | + hasNotchAbove: true, |
| 112 | + hasNotchBelow: true, |
| 113 | + bBoxNesting: [{ w: 10, h: 10 }], |
| 114 | + secondaryLabel: false, |
| 115 | + }, |
| 116 | + }, |
| 117 | + ]; |
| 118 | + |
| 119 | + testCases.forEach(({ name, input }) => { |
| 120 | + it(`generates path correctly: ${name}`, () => { |
| 121 | + const result = generatePath(input as any); |
| 122 | + expect(typeof result.path).toBe('string'); |
| 123 | + expect(result.path.length).toBeGreaterThan(0); |
| 124 | + }); |
| 125 | + }); |
| 126 | +}); |
0 commit comments