Skip to content

Commit

Permalink
fix: set the size correctly for real part in slicing function (#2973)
Browse files Browse the repository at this point in the history
* fix: set the size correctly for real part in slicing function

* test: slicing tool
  • Loading branch information
hamed-musallam committed Mar 19, 2024
1 parent 92fd75d commit 47233fc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/data/data2d/Spectrum2D/getSlice.ts
Expand Up @@ -104,7 +104,7 @@ export function getSlice(
function initiateData(from: number, to: number, size: number): NmrData1D {
return {
x: xSequentialFillFromTo({ from, to, size }),
re: new Float64Array(length),
re: new Float64Array(size),
};
}

Expand Down
28 changes: 28 additions & 0 deletions test-e2e/tools/slicing.test.ts
@@ -0,0 +1,28 @@
import { test, expect } from '@playwright/test';

import NmriumPage from '../NmriumPage';

test('Slicing too should show 1d (horizontal and vertical) traces', async ({
page,
}) => {
const nmrium = await NmriumPage.create(page);
await nmrium.open2D();

await nmrium.clickTool('slicing');

await nmrium.viewer.moveMouse({ x: 200, y: 200 });

const horizontalPath = (await nmrium.page.getAttribute(
`_react=HorizontalSliceChart >> path >> nth=0`,
'd',
)) as string;
expect(horizontalPath.length).toBeGreaterThan(1000);
expect(horizontalPath).not.toContain('NaN');

const verticalPath = (await nmrium.page.getAttribute(
`_react=VerticalSliceChart >> path >> nth=0`,
'd',
)) as string;
expect(verticalPath.length).toBeGreaterThan(1000);
expect(verticalPath).not.toContain('NaN');
});

0 comments on commit 47233fc

Please sign in to comment.