Skip to content

Commit 2125635

Browse files
committed
update test
1 parent e34ab77 commit 2125635

File tree

1 file changed

+47
-13
lines changed

1 file changed

+47
-13
lines changed

src/SankeyPanel.test.tsx

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,20 @@ describe('SankeyPanel', () => {
108108
});
109109

110110
it('should call parseData with correct parameters', () => {
111-
render(<SankeyPanel data={mockData} options={defaultOptions} width={800} height={600} id="test-panel" />);
111+
render(
112+
<svg>
113+
<SankeyPanel data={mockData} options={defaultOptions} width={800} height={600} id="test-panel" />
114+
</svg>
115+
);
112116

113117
expect(parseData).toHaveBeenCalledWith(mockData, defaultOptions, defaultOptions.monochrome, defaultOptions.color);
114118
});
115119

116120
it('should pass correct props to Sankey component', () => {
117121
const { getByTestId } = render(
118-
<SankeyPanel data={mockData} options={defaultOptions} width={800} height={600} id="test-panel" />
122+
<svg>
123+
<SankeyPanel data={mockData} options={defaultOptions} width={800} height={600} id="test-panel" />
124+
</svg>
119125
);
120126

121127
const sankeyMock = getByTestId('sankey-mock');
@@ -127,7 +133,11 @@ describe('SankeyPanel', () => {
127133

128134
it('should handle monochrome option', () => {
129135
const monochromeOptions = { ...defaultOptions, monochrome: true, color: 'dark-red' };
130-
render(<SankeyPanel data={mockData} options={monochromeOptions} width={800} height={600} id="test-panel" />);
136+
render(
137+
<svg>
138+
<SankeyPanel data={mockData} options={monochromeOptions} width={800} height={600} id="test-panel" />
139+
</svg>
140+
);
131141

132142
expect(parseData).toHaveBeenCalledWith(mockData, monochromeOptions, true, 'dark-red');
133143
});
@@ -139,25 +149,33 @@ describe('SankeyPanel', () => {
139149
});
140150

141151
const { container } = render(
142-
<SankeyPanel data={mockData} options={defaultOptions} width={800} height={600} id="test-panel" />
152+
<svg>
153+
<SankeyPanel data={mockData} options={defaultOptions} width={800} height={600} id="test-panel" />
154+
</svg>
143155
);
144156

145157
expect(consoleErrorSpy).toHaveBeenCalledWith('parsing error: ', expect.any(Error));
146-
expect(container.querySelector('g')).toBeInTheDocument();
158+
expect(container.querySelector('svg')).toBeInTheDocument();
147159

148160
consoleErrorSpy.mockRestore();
149161
});
150162

151163
it('should handle different panel dimensions', () => {
152164
const { getByTestId, rerender } = render(
153-
<SankeyPanel data={mockData} options={defaultOptions} width={400} height={300} id="test-panel" />
165+
<svg>
166+
<SankeyPanel data={mockData} options={defaultOptions} width={400} height={300} id="test-panel" />
167+
</svg>
154168
);
155169

156170
let sankeyMock = getByTestId('sankey-mock');
157171
expect(sankeyMock.getAttribute('data-width')).toBe('400');
158172
expect(sankeyMock.getAttribute('data-height')).toBe('300');
159173

160-
rerender(<SankeyPanel data={mockData} options={defaultOptions} width={1200} height={800} id="test-panel" />);
174+
rerender(
175+
<svg>
176+
<SankeyPanel data={mockData} options={defaultOptions} width={1200} height={800} id="test-panel" />
177+
</svg>
178+
);
161179

162180
sankeyMock = getByTestId('sankey-mock');
163181
expect(sankeyMock.getAttribute('data-width')).toBe('1200');
@@ -166,13 +184,19 @@ describe('SankeyPanel', () => {
166184

167185
it('should update when options change', () => {
168186
const { rerender } = render(
169-
<SankeyPanel data={mockData} options={defaultOptions} width={800} height={600} id="test-panel" />
187+
<svg>
188+
<SankeyPanel data={mockData} options={defaultOptions} width={800} height={600} id="test-panel" />
189+
</svg>
170190
);
171191

172192
expect(parseData).toHaveBeenCalledTimes(1);
173193

174194
const newOptions = { ...defaultOptions, nodeWidth: 50 };
175-
rerender(<SankeyPanel data={mockData} options={newOptions} width={800} height={600} id="test-panel" />);
195+
rerender(
196+
<svg>
197+
<SankeyPanel data={mockData} options={newOptions} width={800} height={600} id="test-panel" />
198+
</svg>
199+
);
176200

177201
expect(parseData).toHaveBeenCalledTimes(2);
178202
});
@@ -201,14 +225,20 @@ describe('SankeyPanel', () => {
201225
]);
202226

203227
const { container } = render(
204-
<SankeyPanel data={emptyData} options={defaultOptions} width={800} height={600} id="test-panel" />
228+
<svg>
229+
<SankeyPanel data={emptyData} options={defaultOptions} width={800} height={600} id="test-panel" />
230+
</svg>
205231
);
206232

207-
expect(container.querySelector('g')).toBeInTheDocument();
233+
expect(container.querySelector('svg')).toBeInTheDocument();
208234
});
209235

210236
it('should apply theme text color', () => {
211-
render(<SankeyPanel data={mockData} options={defaultOptions} width={800} height={600} id="test-panel" />);
237+
render(
238+
<svg>
239+
<SankeyPanel data={mockData} options={defaultOptions} width={800} height={600} id="test-panel" />
240+
</svg>
241+
);
212242

213243
// The component should use theme.colors.text.primary for textColor
214244
// This is verified by the mock returning '#FFFFFF'
@@ -222,7 +252,11 @@ describe('SankeyPanel', () => {
222252
nodePadding: 40,
223253
};
224254

225-
render(<SankeyPanel data={customOptions} options={customOptions} width={800} height={600} id="test-panel" />);
255+
render(
256+
<svg>
257+
<SankeyPanel data={customOptions} options={customOptions} width={800} height={600} id="test-panel" />
258+
</svg>
259+
);
226260

227261
expect(parseData).toHaveBeenCalled();
228262
});

0 commit comments

Comments
 (0)