From bda5bc14ea05ff5c5a65879ba194fbecdef38d65 Mon Sep 17 00:00:00 2001 From: Brenton Alker Date: Wed, 3 Oct 2018 17:50:30 +0100 Subject: [PATCH] simple-cipher: Disallow mixed case key A solution that checks if the key is valid (i.e. only contains alpha ascii lower-case letters) by testing if (key === key.toUpperCase()) { throw new Error('Bad key') }` passes the current "throws an error with an all caps key" test but allows mixed-case keys, which should actually be invalid. --- exercises/simple-cipher/simple-cipher.spec.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exercises/simple-cipher/simple-cipher.spec.js b/exercises/simple-cipher/simple-cipher.spec.js index 2f27067a17..745da6503b 100644 --- a/exercises/simple-cipher/simple-cipher.spec.js +++ b/exercises/simple-cipher/simple-cipher.spec.js @@ -45,6 +45,12 @@ describe('Incorrect key cipher', () => { }).toThrow(new Error('Bad key')); }); + xtest('throws an error with a mixed-case key', () => { + expect(() => { + new Cipher('ABcdEF'); + }).toThrow(new Error('Bad key')); + }); + xtest('throws an error with a numeric key', () => { expect(() => { new Cipher('12345');