Skip to content

Commit

Permalink
SOF-7354: add snapshot test for colors of atoms with labels
Browse files Browse the repository at this point in the history
  • Loading branch information
pranabdas committed May 9, 2024
1 parent d165223 commit 481cb88
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion tests/__tests__/wave.js
@@ -1,4 +1,4 @@
import { getWaveInstance } from "../enums";
import { getWaveInstance, getFeOWaveInstance } from "../enums";

Check warning on line 1 in tests/__tests__/wave.js

View workflow job for this annotation

GitHub Actions / run-tests

Run autofix to sort these imports!
import { takeSnapshotAndAssertEqualityAsync } from "../utils";

test("wave", async () => {
Expand All @@ -19,3 +19,14 @@ test("atomRepetitions", async () => {
wave.rebuildScene();
return takeSnapshotAndAssertEqualityAsync(wave.renderer.getContext(), "atomRepetitions");
});

test("colorsOfAtomsWithLabels", async () => {
const wave = getFeOWaveInstance();
// zoom-out to get full view of the cell
wave.toggleOrbitControls();
wave.renderer.domElement.dispatchEvent(new WheelEvent("wheel", { deltaY: 1 }));
wave.renderer.domElement.dispatchEvent(new WheelEvent("wheel", { deltaY: 1 }));
wave.renderer.domElement.dispatchEvent(new WheelEvent("wheel", { deltaY: 1 }));
wave.renderer.domElement.dispatchEvent(new WheelEvent("wheel", { deltaY: 1 }));
return takeSnapshotAndAssertEqualityAsync(wave.renderer.getContext(), "colorsOfAtomsWithLabels");

Check failure on line 31 in tests/__tests__/wave.js

View workflow job for this annotation

GitHub Actions / run-tests

Replace `wave.renderer.getContext(),·"colorsOfAtomsWithLabels"` with `⏎········wave.renderer.getContext(),⏎········"colorsOfAtomsWithLabels",⏎····`
});
13 changes: 13 additions & 0 deletions tests/enums.js
Expand Up @@ -19,6 +19,10 @@ export const ELEMENT_PROPERTIES = {
const materialJsonFilePath = path.resolve(__dirname, "fixtures/material.json");
export const MATERIAL_CONFIG = JSON.parse(fs.readFileSync(materialJsonFilePath));

// material config for material with atomic labels
const FeOJsonFilePath = path.resolve(__dirname, "fixtures/FeO.json");
export const FeO_CONFIG = JSON.parse(fs.readFileSync(FeOJsonFilePath));

export const WAVE_SETTINGS = {
atomRadiiScale: 0.2,
repetitions: 1,
Expand All @@ -32,3 +36,12 @@ export function getWaveInstance(settings, material = new Made.Material(MATERIAL_
settings: settings || WAVE_SETTINGS,
});
}

export function getFeOWaveInstance(settings, material = new Made.Material(FeO_CONFIG)) {
return new Wave({
DOMElement: createElement("div", ELEMENT_PROPERTIES),
structure: material,
cell: material.Lattice.unitCell,
settings: settings || WAVE_SETTINGS,
});
}
3 changes: 3 additions & 0 deletions tests/fixtures/FeO.json
Git LFS file not shown

0 comments on commit 481cb88

Please sign in to comment.