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

Commit 8771698

Browse files
author
James Collier
committed
Fix tests
Also prepare a point release for npm.
1 parent bf1c85d commit 8771698

4 files changed

Lines changed: 77 additions & 13 deletions

File tree

ChangeLog.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [3.0.1] - 2023-07-20
11+
12+
### Fixed
13+
14+
- Correct tests and fix a couple bugs that they revealed.
15+
16+
1017
## [3.0.0] - 2023-07-20
1118

1219
### Added
@@ -41,7 +48,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4148

4249
Initial release
4350

44-
[unreleased]: https://github.com/vibbits/react-2d-molecule/compare/v3.0.0...HEAD
51+
[unreleased]: https://github.com/vibbits/react-2d-molecule/compare/v3.0.1...HEAD
52+
[3.0.1]: https://github.com/vibbits/react-2d-molecule/compare/v3.0.0...v3.0.1
4553
[3.0.0]: https://github.com/vibbits/react-2d-molecule/compare/v2.0.0...v3.0.0
4654
[2.0.0]: https://github.com/vibbits/react-2d-molecule/compare/v1.0.2...v2.0.0
4755
[1.0.2]: https://github.com/vibbits/react-2d-molecule/compare/v1.0.1...v1.0.2

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vibbioinfocore/react-2d-molecule",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "A React component to display molecule structures in a 2D SVG",
55
"browser": "dist/index.js",
66
"main": "./dist/index.js",

src/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type BondVariant =
66
| "UNSPECIFIED"
77
| "SINGLE"
88
| "DOUBLE"
9-
| "TRIPPLE"
9+
| "TRIPLE"
1010
| "QUADRUPLE"
1111
| "QUINTUPLE"
1212
| "HEXTUPLE"
@@ -354,7 +354,13 @@ const Bonds: React.FC<{ molecule: MoleculeData }> = ({ molecule }) => {
354354
<TripleBond key={`triplebond-${i}`} source={f} sink={t} />
355355
);
356356
case "DOUBLE-EITHERDOUBLE":
357-
return <EitherDoubleBond source={f} sink={t} />;
357+
return (
358+
<EitherDoubleBond
359+
key={`eitherdouble-${i}`}
360+
source={f}
361+
sink={t}
362+
/>
363+
);
358364
default:
359365
return (
360366
<UnimplementedBond

test/molecule.test.tsx

Lines changed: 59 additions & 9 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: [{ atoms: [0, 1], bond: "SINGLE" }],
33+
bonds: [{ atoms: [[0, 1, "SINGLE"]] }],
3434
};
3535
const { container } = render(<Molecule molecule={data} />);
3636

@@ -49,7 +49,45 @@ describe("Molecule component", () => {
4949
{ x: 0, y: 0, element: "Cl" },
5050
{ x: 10, y: 10, element: "Cl" },
5151
],
52-
bonds: [{ atoms: [0, 1], bond: "DOUBLE" }],
52+
bonds: [{ atoms: [[0, 1, "DOUBLE"]] }],
53+
};
54+
const { container } = render(<Molecule molecule={data} />);
55+
56+
// chlorine atom labels should displayed
57+
expect(screen.queryAllByText("Cl")).toHaveLength(2);
58+
59+
// The lines
60+
expect(container.querySelectorAll("line")).toHaveLength(2);
61+
});
62+
63+
test("Display a triple bond", () => {
64+
const data: MoleculeData = {
65+
width: 10,
66+
height: 10,
67+
atoms: [
68+
{ x: 0, y: 0, element: "Cl" },
69+
{ x: 10, y: 10, element: "Cl" },
70+
],
71+
bonds: [{ atoms: [[0, 1, "TRIPLE"]] }],
72+
};
73+
const { container } = render(<Molecule molecule={data} />);
74+
75+
// chlorine atom labels should displayed
76+
expect(screen.queryAllByText("Cl")).toHaveLength(2);
77+
78+
// The lines
79+
expect(container.querySelectorAll("line")).toHaveLength(3);
80+
});
81+
82+
test("Display an EitherDouble bond", () => {
83+
const data: MoleculeData = {
84+
width: 10,
85+
height: 10,
86+
atoms: [
87+
{ x: 0, y: 0, element: "Cl" },
88+
{ x: 10, y: 10, element: "Cl" },
89+
],
90+
bonds: [{ atoms: [[0, 1, "DOUBLE"]], direction: "EITHERDOUBLE" }],
5391
};
5492
const { container } = render(<Molecule molecule={data} />);
5593

@@ -68,7 +106,7 @@ describe("Molecule component", () => {
68106
{ x: 0, y: 0, element: "Cl" },
69107
{ x: 10, y: 10, element: "H" },
70108
],
71-
bonds: [{ atoms: [0, 1], bond: "SINGLE", direction: "BEGINWEDGE" }],
109+
bonds: [{ atoms: [[0, 1, "SINGLE"]], direction: "BEGINWEDGE" }],
72110
};
73111
const { container } = render(<Molecule molecule={data} />);
74112

@@ -88,7 +126,7 @@ describe("Molecule component", () => {
88126
{ x: 0, y: 0, element: "Cl" },
89127
{ x: 10, y: 10, element: "C" },
90128
],
91-
bonds: [{ atoms: [0, 1], bond: "SINGLE", direction: "BEGINWEDGE" }],
129+
bonds: [{ atoms: [[0, 1, "SINGLE"]], direction: "BEGINWEDGE" }],
92130
};
93131
const { container } = render(<Molecule molecule={data} />);
94132

@@ -108,7 +146,7 @@ describe("Molecule component", () => {
108146
{ x: 0, y: 0, element: "Cl" },
109147
{ x: 5, y: 5, element: "H" },
110148
],
111-
bonds: [{ atoms: [0, 1], bond: "SINGLE", direction: "BEGINDASH" }],
149+
bonds: [{ atoms: [[0, 1, "SINGLE"]], direction: "BEGINDASH" }],
112150
};
113151
const { container } = render(<Molecule molecule={data} />);
114152

@@ -128,7 +166,7 @@ describe("Molecule component", () => {
128166
{ x: 0, y: 0, element: "Cl" },
129167
{ x: 5, y: 5, element: "C" },
130168
],
131-
bonds: [{ atoms: [0, 1], bond: "SINGLE", direction: "BEGINDASH" }],
169+
bonds: [{ atoms: [[0, 1, "SINGLE"]], direction: "BEGINDASH" }],
132170
};
133171
const { container } = render(<Molecule molecule={data} />);
134172

@@ -152,7 +190,19 @@ describe("Molecule component", () => {
152190
{ x: 0, y: 2, element: "F" },
153191
{ x: 0, y: 1, element: "F" },
154192
],
155-
bonds: [{ atoms: [0, 1, 2, 3, 4, 5], bond: "AROMATIC" }],
193+
bonds: [
194+
{
195+
atoms: [
196+
[0, 1, "SINGLE"],
197+
[1, 2, "DOUBLE"],
198+
[2, 3, "SINGLE"],
199+
[3, 4, "DOUBLE"],
200+
[4, 5, "SINGLE"],
201+
[5, 1, "DOUBLE"],
202+
],
203+
tag: "RING",
204+
},
205+
],
156206
};
157207
const { container } = render(<Molecule molecule={data} />);
158208

@@ -168,7 +218,7 @@ describe("Molecule component", () => {
168218
width: 10,
169219
height: 10,
170220
atoms: [{ x: 5, y: 5, element: "A" }],
171-
bonds: [{ atoms: [], bond: "AROMATIC" }],
221+
bonds: [{ atoms: [], tag: "RING" }],
172222
};
173223

174224
const { container } = render(<Molecule molecule={data} />);
@@ -185,7 +235,7 @@ describe("Molecule component", () => {
185235
{ x: 0, y: 0, element: "Cl" },
186236
{ x: 5, y: 5, element: "H" },
187237
],
188-
bonds: [{ atoms: [0, 1], bond: "UNSPECIFIED" }],
238+
bonds: [{ atoms: [[0, 1, "UNSPECIFIED"]] }],
189239
};
190240
render(<Molecule molecule={data} />);
191241

0 commit comments

Comments
 (0)