Skip to content

Sync rna-transcription to 1.3.0 #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});
})