Skip to content

Commit

Permalink
Sync rna-transcription to 1.3.0 (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
SleeplessByte authored and tejasbubane committed Mar 26, 2019
1 parent b91ba55 commit 67906e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
11 changes: 1 addition & 10 deletions exercises/rna-transcription/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,4 @@ const DNA_TO_RNA = {
A: 'U',
};

export const toRna = (dna) => {
const rna = dna.replace(/./g, nucleotide => DNA_TO_RNA[nucleotide]);

if (rna.length !== dna.length) {
// invalid characters in the strand
throw new Error('Invalid input DNA.');
} else {
return rna;
}
};
export const toRna = (dna) => dna.replace(/./g, nucleotide => DNA_TO_RNA[nucleotide]);
27 changes: 7 additions & 20 deletions exercises/rna-transcription/rna-transcription.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toRna } from './rna-transcription';
import { toRna } from './rna-transcription'

describe('Transcriptor', () => {
describe('Transcription', () => {
test('empty rna sequence', () => {
expect(toRna('')).toEqual('');
});
Expand All @@ -13,28 +13,15 @@ describe('Transcriptor', () => {
expect(toRna('G')).toEqual('C');
});

xtest('transcribes adenine to uracil', () => {
expect(toRna('A')).toEqual('U');
});

xtest('transcribes thymine to adenine', () => {
expect(toRna('T')).toEqual('A');
});

xtest('transcribes all dna nucleotides to their rna complements', () => {
expect(toRna('ACGTGGTCTTAA'))
.toEqual('UGCACCAGAAUU');
});

xtest('correctly handles invalid input', () => {
expect(() => toRna('U')).toThrow(new Error('Invalid input DNA.'));
});

xtest('correctly handles completely invalid input', () => {
expect(() => toRna('XXX')).toThrow(new Error('Invalid input DNA.'));
xtest('transcribes adenine to uracil', () => {
expect(toRna('A')).toEqual('U');
});

xtest('correctly handles partially invalid input', () => {
expect(() => toRna('ACGTXXXCTTAA')).toThrow(new Error('Invalid input DNA.'));
xtest('transcribes all dna nucleotides to their rna complements', () => {
expect(toRna('ACGTGGTCTTAA')).toEqual('UGCACCAGAAUU');
});
});
})

0 comments on commit 67906e5

Please sign in to comment.