Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 89489e3

Browse files
author
James Collier
committed
Update tests
1 parent 7e390f1 commit 89489e3

1 file changed

Lines changed: 45 additions & 8 deletions

File tree

test/molecule.test.tsx

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe("Molecule component", () => {
3030
{ x: 0, y: 0, element: "C" },
3131
{ x: 10, y: 10, element: "C" },
3232
],
33-
bonds: [{ source: 0, sink: 1, bond: "SINGLE" }],
33+
bonds: [{ atoms: [0, 1], bond: "SINGLE" }],
3434
};
3535
const { container } = render(<Molecule molecule={data} />);
3636

@@ -49,7 +49,7 @@ describe("Molecule component", () => {
4949
{ x: 0, y: 0, element: "Cl" },
5050
{ x: 10, y: 10, element: "Cl" },
5151
],
52-
bonds: [{ source: 0, sink: 1, bond: "DOUBLE" }],
52+
bonds: [{ atoms: [0, 1], bond: "DOUBLE" }],
5353
};
5454
const { container } = render(<Molecule molecule={data} />);
5555

@@ -68,7 +68,7 @@ describe("Molecule component", () => {
6868
{ x: 0, y: 0, element: "Cl" },
6969
{ x: 10, y: 10, element: "H" },
7070
],
71-
bonds: [{ source: 0, sink: 1, bond: "SINGLE", direction: "BEGINWEDGE" }],
71+
bonds: [{ atoms: [0, 1], bond: "SINGLE", direction: "BEGINWEDGE" }],
7272
};
7373
const { container } = render(<Molecule molecule={data} />);
7474

@@ -88,7 +88,7 @@ describe("Molecule component", () => {
8888
{ x: 0, y: 0, element: "Cl" },
8989
{ x: 10, y: 10, element: "C" },
9090
],
91-
bonds: [{ source: 0, sink: 1, bond: "SINGLE", direction: "BEGINWEDGE" }],
91+
bonds: [{ atoms: [0, 1], bond: "SINGLE", direction: "BEGINWEDGE" }],
9292
};
9393
const { container } = render(<Molecule molecule={data} />);
9494

@@ -108,7 +108,7 @@ describe("Molecule component", () => {
108108
{ x: 0, y: 0, element: "Cl" },
109109
{ x: 5, y: 5, element: "H" },
110110
],
111-
bonds: [{ source: 0, sink: 1, bond: "SINGLE", direction: "BEGINDASH" }],
111+
bonds: [{ atoms: [0, 1], bond: "SINGLE", direction: "BEGINDASH" }],
112112
};
113113
const { container } = render(<Molecule molecule={data} />);
114114

@@ -128,7 +128,7 @@ describe("Molecule component", () => {
128128
{ x: 0, y: 0, element: "Cl" },
129129
{ x: 5, y: 5, element: "C" },
130130
],
131-
bonds: [{ source: 0, sink: 1, bond: "SINGLE", direction: "BEGINDASH" }],
131+
bonds: [{ atoms: [0, 1], bond: "SINGLE", direction: "BEGINDASH" }],
132132
};
133133
const { container } = render(<Molecule molecule={data} />);
134134

@@ -140,6 +140,43 @@ describe("Molecule component", () => {
140140
expect(container.querySelectorAll("line")).toHaveLength(6);
141141
});
142142

143+
test("Display aromatic ring", () => {
144+
const data: MoleculeData = {
145+
width: 10,
146+
height: 10,
147+
atoms: [
148+
{ x: 1, y: 0, element: "F" },
149+
{ x: 2, y: 1, element: "F" },
150+
{ x: 2, y: 2, element: "F" },
151+
{ x: 1, y: 3, element: "F" },
152+
{ x: 0, y: 2, element: "F" },
153+
{ x: 0, y: 1, element: "F" },
154+
],
155+
bonds: [{ atoms: [0, 1, 2, 3, 4, 5], bond: "AROMATIC" }],
156+
};
157+
const { container } = render(<Molecule molecule={data} />);
158+
159+
// atom labels should displayed
160+
expect(screen.queryAllByText("F")).toHaveLength(6);
161+
162+
// The polygon
163+
expect(container.querySelectorAll("line")).toHaveLength(9);
164+
});
165+
166+
test("Empty aromatic ring", () => {
167+
const data: MoleculeData = {
168+
width: 10,
169+
height: 10,
170+
atoms: [{ x: 5, y: 5, element: "A" }],
171+
bonds: [{ atoms: [], bond: "AROMATIC" }],
172+
};
173+
174+
const { container } = render(<Molecule molecule={data} />);
175+
176+
expect(screen.queryAllByText("A")).toHaveLength(1);
177+
expect(container.querySelectorAll("line")).toHaveLength(0);
178+
});
179+
143180
test("Display an unimplemented bond type", () => {
144181
const data: MoleculeData = {
145182
width: 10,
@@ -148,7 +185,7 @@ describe("Molecule component", () => {
148185
{ x: 0, y: 0, element: "Cl" },
149186
{ x: 5, y: 5, element: "H" },
150187
],
151-
bonds: [{ source: 0, sink: 1, bond: "UNSPECIFIED" }],
188+
bonds: [{ atoms: [0, 1], bond: "UNSPECIFIED" }],
152189
};
153190
render(<Molecule molecule={data} />);
154191

@@ -157,7 +194,7 @@ describe("Molecule component", () => {
157194
expect(screen.queryByText("H")).not.toBeNull();
158195

159196
// The unimplemented label
160-
expect(screen.queryByText("?unimplemented?")).not.toBeNull();
197+
expect(screen.queryByText("?UNSPECIFIED-?")).not.toBeNull();
161198
});
162199

163200
test("Carbons respond to button clicks", () => {

0 commit comments

Comments
 (0)