From 141d9d4b0c77cb044945a611074a0d84c3c689f7 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Wed, 25 Jun 2025 13:44:39 +0530 Subject: [PATCH 1/6] Sync tests.toml --- .../protein-translation/.meta/tests.toml | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/exercises/practice/protein-translation/.meta/tests.toml b/exercises/practice/protein-translation/.meta/tests.toml index 02a54c3446..de680e39ef 100644 --- a/exercises/practice/protein-translation/.meta/tests.toml +++ b/exercises/practice/protein-translation/.meta/tests.toml @@ -1,6 +1,16 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[2c44f7bf-ba20-43f7-a3bf-f2219c0c3f98] +description = "Empty RNA sequence results in no proteins" [96d3d44f-34a2-4db4-84cd-fff523e069be] description = "Methionine RNA sequence" @@ -53,6 +63,12 @@ description = "STOP codon RNA sequence 2" [9c2ad527-ebc9-4ace-808b-2b6447cb54cb] description = "STOP codon RNA sequence 3" +[f4d9d8ee-00a8-47bf-a1e3-1641d4428e54] +description = "Sequence of two protein codons translates into proteins" + +[dd22eef3-b4f1-4ad6-bb0b-27093c090a9d] +description = "Sequence of two different protein codons translates into proteins" + [d0f295df-fb70-425c-946c-ec2ec185388e] description = "Translate RNA strand into correct protein list" @@ -70,3 +86,20 @@ description = "Translation stops if STOP codon in middle of three-codon sequence [2c2a2a60-401f-4a80-b977-e0715b23b93d] description = "Translation stops if STOP codon in middle of six-codon sequence" + +[f6f92714-769f-4187-9524-e353e8a41a80] +description = "Sequence of two non-STOP codons does not translate to a STOP codon" + +[1e75ea2a-f907-4994-ae5c-118632a1cb0f] +description = "Non-existing codon can't translate" +include = false + +[9eac93f3-627a-4c90-8653-6d0a0595bc6f] +description = "Unknown amino acids, not part of a codon, can't translate" +reimplements = "1e75ea2a-f907-4994-ae5c-118632a1cb0f" + +[9d73899f-e68e-4291-b1e2-7bf87c00f024] +description = "Incomplete RNA sequence can't translate" + +[43945cf7-9968-402d-ab9f-b8a28750b050] +description = "Incomplete RNA sequence can translate if valid until a STOP codon" From 57466b99d280e14fca4353726b4e69c3b9baea76 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Wed, 25 Jun 2025 13:45:01 +0530 Subject: [PATCH 2/6] Update test file --- .../protein-translation/protein-translation.spec.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/practice/protein-translation/protein-translation.spec.js b/exercises/practice/protein-translation/protein-translation.spec.js index 529ae0b20f..ffc3996d11 100644 --- a/exercises/practice/protein-translation/protein-translation.spec.js +++ b/exercises/practice/protein-translation/protein-translation.spec.js @@ -2,7 +2,7 @@ import { describe, expect, test, xtest } from '@jest/globals'; import { translate } from './protein-translation'; describe('ProteinTranslation', () => { - test('Empty RNA has no proteins', () => { + test('Empty RNA sequence results in no proteins', () => { expect(translate()).toEqual([]); }); @@ -71,13 +71,13 @@ describe('ProteinTranslation', () => { 'Tyrosine', ]); }); - }); - describe('Unexpected strands', () => { - xtest("Non-existing codon can't translate", () => { - expect(() => translate('AAA')).toThrow(new Error('Invalid codon')); + xtest('Sequence of two non-STOP codons does not translate to a STOP codon', () => { + expect(translate('AUGAUG')).toEqual(['Methionine', 'Methionine']); }); + }); + describe('Unexpected strands', () => { xtest("Unknown amino acids, not part of a codon, can't translate", () => { expect(() => translate('XYZ')).toThrow(new Error('Invalid codon')); }); From 8c287ae15c15358c5cd6b5176233e92d672d9395 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Wed, 25 Jun 2025 13:45:19 +0530 Subject: [PATCH 3/6] Congiure config.json --- exercises/practice/protein-translation/.meta/config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/practice/protein-translation/.meta/config.json b/exercises/practice/protein-translation/.meta/config.json index 17633d3390..31f3c72c81 100644 --- a/exercises/practice/protein-translation/.meta/config.json +++ b/exercises/practice/protein-translation/.meta/config.json @@ -4,6 +4,7 @@ ], "contributors": [ "ankorGH", + "jagdish-15", "SleeplessByte", "tejasbubane", "WebCu" From 7a5838a2c9d3c9c85ff1201ec312b29640266ca6 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Sun, 29 Jun 2025 19:33:10 +0530 Subject: [PATCH 4/6] Update test naming logic for single codons --- .../protein-translation/protein-translation.spec.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/exercises/practice/protein-translation/protein-translation.spec.js b/exercises/practice/protein-translation/protein-translation.spec.js index ffc3996d11..44a2ef8346 100644 --- a/exercises/practice/protein-translation/protein-translation.spec.js +++ b/exercises/practice/protein-translation/protein-translation.spec.js @@ -20,7 +20,11 @@ describe('ProteinTranslation', () => { mapping.forEach(([protein, codons]) => { codons.forEach((codon, index) => { const seq = index + 1; - xtest(`${protein} RNA sequence ${seq} translates into ${protein}`, () => { + const message = + codons.length == 1 + ? `${protein} RNA sequence` + : `${protein} RNA sequence ${seq}`; + xtest(message, () => { expect(translate(codon)).toEqual([protein]); }); }); From d19539e116829186844c4f37966a1d920768c972 Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Tue, 22 Jul 2025 17:15:53 +0530 Subject: [PATCH 5/6] Unrool test loop --- .../protein-translation.spec.js | 88 ++++++++++++------- 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/exercises/practice/protein-translation/protein-translation.spec.js b/exercises/practice/protein-translation/protein-translation.spec.js index 44a2ef8346..59ff25fce2 100644 --- a/exercises/practice/protein-translation/protein-translation.spec.js +++ b/exercises/practice/protein-translation/protein-translation.spec.js @@ -7,37 +7,65 @@ describe('ProteinTranslation', () => { }); describe('Single codons', () => { - const mapping = [ - ['Methionine', ['AUG']], - ['Phenylalanine', ['UUU', 'UUC']], - ['Leucine', ['UUA', 'UUG']], - ['Serine', ['UCU', 'UCC', 'UCA', 'UCG']], - ['Tyrosine', ['UAU', 'UAC']], - ['Cysteine', ['UGU', 'UGC']], - ['Tryptophan', ['UGG']], - ]; - - mapping.forEach(([protein, codons]) => { - codons.forEach((codon, index) => { - const seq = index + 1; - const message = - codons.length == 1 - ? `${protein} RNA sequence` - : `${protein} RNA sequence ${seq}`; - xtest(message, () => { - expect(translate(codon)).toEqual([protein]); - }); - }); - }); - - const stopCodons = ['UAA', 'UAG', 'UGA']; - - stopCodons.forEach((codon, index) => { - xtest(`STOP codon RNA sequence ${index + 1}`, () => { - expect(translate(codon)).toEqual([]); - }); + xtest('Methionine RNA sequence', () => { + expect(translate('AUG')).toEqual(['Methionine']); }); - }); + + xtest('Phenylalanine RNA sequence 1', () => { + expect(translate('UUU')).toEqual(['Phenylalanine']); + }); + xtest('Phenylalanine RNA sequence 2', () => { + expect(translate('UUC')).toEqual(['Phenylalanine']); + }); + + xtest('Leucine RNA sequence 1', () => { + expect(translate('UUA')).toEqual(['Leucine']); + }); + xtest('Leucine RNA sequence 2', () => { + expect(translate('UUG')).toEqual(['Leucine']); + }); + + xtest('Serine RNA sequence 1', () => { + expect(translate('UCU')).toEqual(['Serine']); + }); + xtest('Serine RNA sequence 2', () => { + expect(translate('UCC')).toEqual(['Serine']); + }); + xtest('Serine RNA sequence 3', () => { + expect(translate('UCA')).toEqual(['Serine']); + }); + xtest('Serine RNA sequence 4', () => { + expect(translate('UCG')).toEqual(['Serine']); + }); + + xtest('Tyrosine RNA sequence 1', () => { + expect(translate('UAU')).toEqual(['Tyrosine']); + }); + xtest('Tyrosine RNA sequence 2', () => { + expect(translate('UAC')).toEqual(['Tyrosine']); + }); + + xtest('Cysteine RNA sequence 1', () => { + expect(translate('UGU')).toEqual(['Cysteine']); + }); + xtest('Cysteine RNA sequence 2', () => { + expect(translate('UGC')).toEqual(['Cysteine']); + }); + + xtest('Tryptophan RNA sequence', () => { + expect(translate('UGG')).toEqual(['Tryptophan']); + }); + + xtest('STOP codon RNA sequence 1', () => { + expect(translate('UAA')).toEqual([]); + }); + xtest('STOP codon RNA sequence 2', () => { + expect(translate('UAG')).toEqual([]); + }); + xtest('STOP codon RNA sequence 3', () => { + expect(translate('UGA')).toEqual([]); + }); + }); describe('Multiple codons', () => { xtest('Sequence of two protein codons translates into proteins', () => { From fd1dd4ec37f96912a2ce3f0bf69e3fe6d5b6814e Mon Sep 17 00:00:00 2001 From: Jagdish Prajapati Date: Tue, 22 Jul 2025 17:18:31 +0530 Subject: [PATCH 6/6] Run format.mjs --- .../practice/protein-translation/protein-translation.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/practice/protein-translation/protein-translation.spec.js b/exercises/practice/protein-translation/protein-translation.spec.js index 59ff25fce2..63359ec9ca 100644 --- a/exercises/practice/protein-translation/protein-translation.spec.js +++ b/exercises/practice/protein-translation/protein-translation.spec.js @@ -10,7 +10,7 @@ describe('ProteinTranslation', () => { xtest('Methionine RNA sequence', () => { expect(translate('AUG')).toEqual(['Methionine']); }); - + xtest('Phenylalanine RNA sequence 1', () => { expect(translate('UUU')).toEqual(['Phenylalanine']); }); @@ -65,7 +65,7 @@ describe('ProteinTranslation', () => { xtest('STOP codon RNA sequence 3', () => { expect(translate('UGA')).toEqual([]); }); - }); + }); describe('Multiple codons', () => { xtest('Sequence of two protein codons translates into proteins', () => {