From 3d2f7b8aedb2dc8c3d140bde304b2772bf83226c Mon Sep 17 00:00:00 2001 From: Derk-Jan Karrenbeld Date: Wed, 10 Apr 2019 19:34:36 +0200 Subject: [PATCH] Sync simple-cipher to version 2.0.0 Following https://github.com/exercism/problem-specifications/pull/1346 and https://github.com/exercism/problem-specifications/pull/1462 --- exercises/simple-cipher/README.md | 22 +++++++------- exercises/simple-cipher/simple-cipher.test.ts | 30 ++----------------- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/exercises/simple-cipher/README.md b/exercises/simple-cipher/README.md index c9270de34..681d3f794 100644 --- a/exercises/simple-cipher/README.md +++ b/exercises/simple-cipher/README.md @@ -13,8 +13,8 @@ for A, and so with the others." Ciphers are very straight-forward algorithms that allow us to render text less readable while still allowing easy deciphering. They are -vulnerable to many forms of cryptoanalysis, but we are lucky that -generally our little sisters are not cryptoanalysts. +vulnerable to many forms of cryptanalysis, but we are lucky that +generally our little sisters are not cryptanalysts. The Caesar Cipher was used for some messages from Julius Caesar that were sent afield. Now Caesar knew that the cipher wasn't very good, but @@ -61,10 +61,7 @@ substitution cipher a little more fault tolerant by providing a source of randomness and ensuring that the key contains only lowercase letters. If someone doesn't submit a key at all, generate a truly random key of -at least 100 characters in length. - -If the key submitted is not composed only of lowercase letters, your -solution should handle the error in a language-appropriate way. +at least 100 alphanumeric characters in length. ## Extensions @@ -83,10 +80,10 @@ on Wikipedia][dh] for one of the first implementations of this scheme. ## Setup -Go through the setup instructions for TypeScript to -install the necessary dependencies: +Go through the setup instructions for TypeScript to install the necessary +dependencies: -http://exercism.io/languages/typescript +[https://exercism.io/tracks/typescript/installation](https://exercism.io/tracks/typescript/installation) ## Requirements @@ -104,11 +101,16 @@ Execute the tests with: $ yarn test ``` +In the test suites all tests but the first have been skipped. +Once you get a test passing, you can enable the next one by changing `xit` to +`it`. ## Source Substitution Cipher at Wikipedia [http://en.wikipedia.org/wiki/Substitution_cipher](http://en.wikipedia.org/wiki/Substitution_cipher) ## Submitting Incomplete Solutions -It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +It's possible to submit an incomplete solution so you can see how others have +completed the exercise. diff --git a/exercises/simple-cipher/simple-cipher.test.ts b/exercises/simple-cipher/simple-cipher.test.ts index 28e7c7693..02d2f4fb6 100644 --- a/exercises/simple-cipher/simple-cipher.test.ts +++ b/exercises/simple-cipher/simple-cipher.test.ts @@ -38,32 +38,6 @@ describe('Random key cipher', () => { }) }) -describe('Incorrect key cipher', () => { - xit('throws an error with an all caps key', () => { - expect(() => { - new SimpleCipher('ABCDEF') - }).toThrowError('Bad key') - }) - - xit('throws an error with a mixed case key', () => { - expect(() => { - new SimpleCipher('AbcdEF') - }).toThrowError('Bad key') - }) - - xit('throws an error with a numeric key', () => { - expect(() => { - new SimpleCipher('12345') - }).toThrow('Bad key') - }) - - xit('throws an error with an empty key', () => { - expect(() => { - new SimpleCipher('') - }).toThrow('Bad key') - }) -}) - describe('Substitution cipher', () => { const key = 'abcdefghij' const simpleCipher = new SimpleCipher(key) @@ -97,12 +71,12 @@ describe('Substitution cipher', () => { expect(simpleCipher.decode('zabcdefghi')).toEqual('zzzzzzzzzz') }) - xit('can handle messages longer than the key (encode)', () => { + xit('can encode messages longer than the key"', () => { expect(new SimpleCipher('abc').encode('iamapandabear')) .toEqual('iboaqcnecbfcr') }) - xit('can handle messages longer than the key (decode)', () => { + xit('can decode messages longer than the key', () => { expect(new SimpleCipher('abc').decode('iboaqcnecbfcr')) .toEqual('iamapandabear') })