Skip to content

Commit

Permalink
Add tests files
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad committed Sep 4, 2024
1 parent bd0d1a4 commit e9f1aa7
Show file tree
Hide file tree
Showing 7 changed files with 4,159 additions and 20 deletions.
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const config: Config = {
// bail: 0,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "C:\\Users\\phili\\AppData\\Local\\Temp\\jest",
// cacheDirectory: "",

// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,
Expand Down
32 changes: 17 additions & 15 deletions src/sdfg_diff_viewr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
WebSDFV,
} from '.';
import { DiffOverlay } from './overlays/diff_overlay';
import { RendererUIFeature, SDFGRenderer } from './renderer/renderer';
import { SDFGRenderer } from './renderer/renderer';
import _ from 'lodash';

type ChangeState = 'nodiff' | 'changed' | 'added' | 'removed';
Expand Down Expand Up @@ -67,7 +67,9 @@ export abstract class SDFGDiffViewer implements ISDFV {
this.rightRenderer.destroy();
}

protected async diff(graphA: JsonSDFG, graphB: JsonSDFG): Promise<DiffMap> {
public static async diff(
graphA: JsonSDFG, graphB: JsonSDFG
): Promise<DiffMap> {
if (!graphA.attributes.guid || !graphB.attributes.guid) {
return {
addedKeys: new Set(),
Expand Down Expand Up @@ -143,12 +145,11 @@ export abstract class SDFGDiffViewer implements ISDFV {
changedKeys.add(key);
}

this.diffMap = {
return {
addedKeys,
removedKeys,
changedKeys,
};
return this.diffMap;
}

public abstract get linkedUI(): ISDFVUserInterface;
Expand Down Expand Up @@ -360,17 +361,6 @@ export class WebSDFGDiffViewer extends SDFGDiffViewer {
leftRenderer.setSDFVInstance(viewer);
rightRenderer.setSDFVInstance(viewer);

viewer.diff(graphA, graphB).then(diff => {
const leftOverlay = new DiffOverlay(leftRenderer, diff);
const rightOverlay = new DiffOverlay(rightRenderer, diff);
leftRenderer.overlayManager.register_overlay_instance(
leftOverlay
);
rightRenderer.overlayManager.register_overlay_instance(
rightOverlay
);
});

const rendererSelectionChange = (renderer: SDFGRenderer) => {
const selectedElements = renderer.get_selected_elements();
let element;
Expand Down Expand Up @@ -400,6 +390,18 @@ export class WebSDFGDiffViewer extends SDFGDiffViewer {
rendererSelectionChange(rightRenderer);
});

SDFGDiffViewer.diff(graphA, graphB).then(diff => {
viewer.diffMap = diff;
const leftOverlay = new DiffOverlay(leftRenderer, diff);
const rightOverlay = new DiffOverlay(rightRenderer, diff);
leftRenderer.overlayManager.register_overlay_instance(
leftOverlay
);
rightRenderer.overlayManager.register_overlay_instance(
rightOverlay
);
});

return viewer;
}

Expand Down
Loading

0 comments on commit e9f1aa7

Please sign in to comment.