Skip to content

Commit a7eea1f

Browse files
author
josh
committed
Fix rendering of AA seqs
1 parent d16f87f commit a7eea1f

5 files changed

Lines changed: 19 additions & 16 deletions

File tree

src/Linear/SeqBlock.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "@testing-library/jest-dom";
2-
import { render, screen } from "@testing-library/react";
2+
import { cleanup, render, screen } from "@testing-library/react";
33

44
import * as React from "react";
55

@@ -73,5 +73,7 @@ describe("SeqBlock", () => {
7373
const seqBlock = screen.getByTestId("la-vz-seq");
7474
expect(seqBlock).toBeTruthy();
7575
expect(seqBlock.textContent).toEqual(seq);
76+
77+
cleanup();
7678
});
7779
});

src/Linear/SeqBlock.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ export class SeqBlock extends React.PureComponent<SeqBlockProps> {
297297
})}
298298
className="la-vz-seqblock"
299299
cursor="text"
300+
data-testid="la-vz-seqblock"
300301
display="block"
301302
height={blockHeight}
302303
id={id}

src/Linear/Translations.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const TranslationRows = ({
3636
translations,
3737
yDiff,
3838
}: TranslationRowsProps) => (
39-
<g className="la-vz-linear-translations">
39+
<g className="la-vz-linear-translation" data-testid="la-vz-linear-translation">
4040
{translations.map((t, i) => (
4141
<TranslationRow
4242
key={`${t.id}-${firstBase}`}

src/SeqViz.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ export default class SeqViz extends React.Component<SeqVizProps, SeqVizState> {
382382
// This is an unfortunate bit of seq checking. We could get a seq directly or from a file parsed to a part.
383383
if (!seq) return <div className="la-vz-seqviz" />;
384384

385-
if (seqType !== "dna" && seqType !== "rna" && translations && translations.length) {
386-
// make the entire sequence the "translation"
385+
// If the seqType is aa, make the entire sequence the "translation"
386+
if (seqType === "aa") {
387387
// TODO: during some grand future refactor, make this cleaner and more transparent to the user
388388
translations = [{ direction: 1, end: seq.length, start: 0 }];
389389
}

src/index.test.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "@testing-library/jest-dom";
2-
import { cleanup, render, screen } from "@testing-library/react";
2+
import { cleanup, render } from "@testing-library/react";
33

44
import * as React from "react";
55

@@ -16,7 +16,7 @@ const props = {
1616
],
1717
name: "test_part",
1818
seq: "ATGGTAGTTAGATAGGGATACCGATAGACTTGAGAGATACCGCATCTATTTACGACCAGCGAGCAG",
19-
testSize: { height: 600, width: 800 },
19+
testSize: { height: 900, width: 800 },
2020
};
2121

2222
describe("SeqViz rendering (React)", () => {
@@ -50,30 +50,30 @@ describe("SeqViz rendering (React)", () => {
5050
});
5151

5252
it("renders with Genbank file string input", async () => {
53-
render(<SeqViz {...props} file={demoPart} />);
54-
expect(screen.getAllByTestId("la-vz-seqviz")).toBeTruthy();
55-
56-
expect(screen.getAllByTestId("la-vz-viewer-container")).toHaveLength(1);
53+
const { getAllByTestId } = render(<SeqViz {...props} file={demoPart} />);
54+
expect(getAllByTestId("la-vz-seqviz")).toBeTruthy();
55+
expect(getAllByTestId("la-vz-viewer-container")).toHaveLength(1);
5756

5857
// Verify the file's sequence is rendered.
5958
// The linear viewer will cut off the end, this is just the prefix
60-
const seqs = screen.getAllByTestId("la-vz-seq");
59+
const seqs = getAllByTestId("la-vz-seq");
6160
const seq = seqs.map(s => s.textContent).join("");
6261
expect(seq).toContain("ttgacagctagctcagtcctaggtactgtgctagcta");
6362
});
6463

6564
it("renders with an Amino Acid sequence", () => {
6665
const aaSeq =
67-
"MSKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKQHDFFKSAMPEGYVQERTIFFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYIMADKQKNGIKVNFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*";
66+
"MSKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKQHDFFKSAMPEGYVQERTIFFKDDGDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*";
6867

69-
const { getAllByTestId, getByTestId } = render(<SeqViz {...props} seq={aaSeq} seqType="aa" viewer="linear" />);
68+
const { getAllByTestId, getByTestId } = render(<SeqViz {...props} seq={aaSeq} viewer="linear" />);
7069
expect(getAllByTestId("la-vz-seqviz")).toBeTruthy();
7170
expect(getByTestId("la-vz-viewer-linear")).toBeTruthy();
7271
expect(getAllByTestId("la-vz-viewer-linear")).toHaveLength(1);
7372

74-
// const seqs = getAllByTestId("la-vz-translation");
75-
// const seq = seqs.map(s => s.textContent).join("");
76-
// expect(seq).toEqual(aaSeq);
73+
const seqs = getAllByTestId("la-vz-linear-translation");
74+
const seq = seqs.map(s => s.textContent).join("");
75+
expect(seq.length).toBeGreaterThan(0);
76+
expect(aaSeq).toContain(seq);
7777
});
7878

7979
it("renders with an externally set Selection prop", () => {

0 commit comments

Comments
 (0)