Skip to content

Commit 17c0f6f

Browse files
authored
Update tests protein translation (#2697)
* Sync tests.toml * Update test file * Congiure config.json * Update test naming logic for single codons * Unrool test loop * Run format.mjs
1 parent adcda70 commit 17c0f6f

File tree

3 files changed

+99
-33
lines changed

3 files changed

+99
-33
lines changed

exercises/practice/protein-translation/.meta/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
],
55
"contributors": [
66
"ankorGH",
7+
"jagdish-15",
78
"SleeplessByte",
89
"tejasbubane",
910
"WebCu"

exercises/practice/protein-translation/.meta/tests.toml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[2c44f7bf-ba20-43f7-a3bf-f2219c0c3f98]
13+
description = "Empty RNA sequence results in no proteins"
414

515
[96d3d44f-34a2-4db4-84cd-fff523e069be]
616
description = "Methionine RNA sequence"
@@ -53,6 +63,12 @@ description = "STOP codon RNA sequence 2"
5363
[9c2ad527-ebc9-4ace-808b-2b6447cb54cb]
5464
description = "STOP codon RNA sequence 3"
5565

66+
[f4d9d8ee-00a8-47bf-a1e3-1641d4428e54]
67+
description = "Sequence of two protein codons translates into proteins"
68+
69+
[dd22eef3-b4f1-4ad6-bb0b-27093c090a9d]
70+
description = "Sequence of two different protein codons translates into proteins"
71+
5672
[d0f295df-fb70-425c-946c-ec2ec185388e]
5773
description = "Translate RNA strand into correct protein list"
5874

@@ -70,3 +86,20 @@ description = "Translation stops if STOP codon in middle of three-codon sequence
7086

7187
[2c2a2a60-401f-4a80-b977-e0715b23b93d]
7288
description = "Translation stops if STOP codon in middle of six-codon sequence"
89+
90+
[f6f92714-769f-4187-9524-e353e8a41a80]
91+
description = "Sequence of two non-STOP codons does not translate to a STOP codon"
92+
93+
[1e75ea2a-f907-4994-ae5c-118632a1cb0f]
94+
description = "Non-existing codon can't translate"
95+
include = false
96+
97+
[9eac93f3-627a-4c90-8653-6d0a0595bc6f]
98+
description = "Unknown amino acids, not part of a codon, can't translate"
99+
reimplements = "1e75ea2a-f907-4994-ae5c-118632a1cb0f"
100+
101+
[9d73899f-e68e-4291-b1e2-7bf87c00f024]
102+
description = "Incomplete RNA sequence can't translate"
103+
104+
[43945cf7-9968-402d-ab9f-b8a28750b050]
105+
description = "Incomplete RNA sequence can translate if valid until a STOP codon"

exercises/practice/protein-translation/protein-translation.spec.js

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,68 @@ import { describe, expect, test, xtest } from '@jest/globals';
22
import { translate } from './protein-translation';
33

44
describe('ProteinTranslation', () => {
5-
test('Empty RNA has no proteins', () => {
5+
test('Empty RNA sequence results in no proteins', () => {
66
expect(translate()).toEqual([]);
77
});
88

99
describe('Single codons', () => {
10-
const mapping = [
11-
['Methionine', ['AUG']],
12-
['Phenylalanine', ['UUU', 'UUC']],
13-
['Leucine', ['UUA', 'UUG']],
14-
['Serine', ['UCU', 'UCC', 'UCA', 'UCG']],
15-
['Tyrosine', ['UAU', 'UAC']],
16-
['Cysteine', ['UGU', 'UGC']],
17-
['Tryptophan', ['UGG']],
18-
];
19-
20-
mapping.forEach(([protein, codons]) => {
21-
codons.forEach((codon, index) => {
22-
const seq = index + 1;
23-
xtest(`${protein} RNA sequence ${seq} translates into ${protein}`, () => {
24-
expect(translate(codon)).toEqual([protein]);
25-
});
26-
});
27-
});
28-
29-
const stopCodons = ['UAA', 'UAG', 'UGA'];
30-
31-
stopCodons.forEach((codon, index) => {
32-
xtest(`STOP codon RNA sequence ${index + 1}`, () => {
33-
expect(translate(codon)).toEqual([]);
34-
});
10+
xtest('Methionine RNA sequence', () => {
11+
expect(translate('AUG')).toEqual(['Methionine']);
12+
});
13+
14+
xtest('Phenylalanine RNA sequence 1', () => {
15+
expect(translate('UUU')).toEqual(['Phenylalanine']);
16+
});
17+
xtest('Phenylalanine RNA sequence 2', () => {
18+
expect(translate('UUC')).toEqual(['Phenylalanine']);
19+
});
20+
21+
xtest('Leucine RNA sequence 1', () => {
22+
expect(translate('UUA')).toEqual(['Leucine']);
23+
});
24+
xtest('Leucine RNA sequence 2', () => {
25+
expect(translate('UUG')).toEqual(['Leucine']);
26+
});
27+
28+
xtest('Serine RNA sequence 1', () => {
29+
expect(translate('UCU')).toEqual(['Serine']);
30+
});
31+
xtest('Serine RNA sequence 2', () => {
32+
expect(translate('UCC')).toEqual(['Serine']);
33+
});
34+
xtest('Serine RNA sequence 3', () => {
35+
expect(translate('UCA')).toEqual(['Serine']);
36+
});
37+
xtest('Serine RNA sequence 4', () => {
38+
expect(translate('UCG')).toEqual(['Serine']);
39+
});
40+
41+
xtest('Tyrosine RNA sequence 1', () => {
42+
expect(translate('UAU')).toEqual(['Tyrosine']);
43+
});
44+
xtest('Tyrosine RNA sequence 2', () => {
45+
expect(translate('UAC')).toEqual(['Tyrosine']);
46+
});
47+
48+
xtest('Cysteine RNA sequence 1', () => {
49+
expect(translate('UGU')).toEqual(['Cysteine']);
50+
});
51+
xtest('Cysteine RNA sequence 2', () => {
52+
expect(translate('UGC')).toEqual(['Cysteine']);
53+
});
54+
55+
xtest('Tryptophan RNA sequence', () => {
56+
expect(translate('UGG')).toEqual(['Tryptophan']);
57+
});
58+
59+
xtest('STOP codon RNA sequence 1', () => {
60+
expect(translate('UAA')).toEqual([]);
61+
});
62+
xtest('STOP codon RNA sequence 2', () => {
63+
expect(translate('UAG')).toEqual([]);
64+
});
65+
xtest('STOP codon RNA sequence 3', () => {
66+
expect(translate('UGA')).toEqual([]);
3567
});
3668
});
3769

@@ -71,13 +103,13 @@ describe('ProteinTranslation', () => {
71103
'Tyrosine',
72104
]);
73105
});
74-
});
75106

76-
describe('Unexpected strands', () => {
77-
xtest("Non-existing codon can't translate", () => {
78-
expect(() => translate('AAA')).toThrow(new Error('Invalid codon'));
107+
xtest('Sequence of two non-STOP codons does not translate to a STOP codon', () => {
108+
expect(translate('AUGAUG')).toEqual(['Methionine', 'Methionine']);
79109
});
110+
});
80111

112+
describe('Unexpected strands', () => {
81113
xtest("Unknown amino acids, not part of a codon, can't translate", () => {
82114
expect(() => translate('XYZ')).toThrow(new Error('Invalid codon'));
83115
});

0 commit comments

Comments
 (0)