Skip to content

Instantly share code, notes, and snippets.

@louislatreille
Last active August 6, 2021 16:05
Show Gist options
  • Save louislatreille/349699047a6b4b7dd4e2eddd64283634 to your computer and use it in GitHub Desktop.
Save louislatreille/349699047a6b4b7dd4e2eddd64283634 to your computer and use it in GitHub Desktop.
(Article - You should aim to forget how your code works)
describe("GIVEN a call to decodeMorse", () => {
[... additional tests to cover non-edge cases ...]
it('THEN it decodes the special SOS code', () => {
Test.assertEquals(decodeMorse('...---...'), 'SOS');
});
it('THEN it decodes the special = code', () => {
Test.assertEquals(decodeMorse('-...-'), '=');
});
describe("AND the input contains trailing spaces", () => {
it('THEN the trailing spaces are removed and ignored in the output', () => {
Test.assertEquals(decodeMorse(' .... . .-.. .-.. --- -- . -.. .. ..- -- '), 'HELLO MEDIUM');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment