-
Notifications
You must be signed in to change notification settings - Fork 0
/
translator.test.js
52 lines (45 loc) · 1.38 KB
/
translator.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { translateStringToMorse } from "./translator.js";
describe("TranslateMorseCode() function", () => {
test("With a null parameter returns undefined", () => {
// arrange
const methodParam = null;
// act
const result = translateStringToMorse(methodParam);
// assert
expect(result).toBe(undefined);
});
test("With an empty parameter returns defined string", () => {
// arrange
const methodParam = "";
const definedString = "There is no Output without an Input";
// act
const result = translateStringToMorse(methodParam);
// assert
expect(result).toBe(definedString);
});
test("Returns '.-' with 'a' parameter", () => {
// arrange
const methodParam = "a";
// act
const result = translateStringToMorse(methodParam);
// assert
expect(result).toBe(".- ");
});
test("Returns correct translation with upperCase parameter", () => {
// arrange
const methodParam = "SOS";
// act
const result = translateStringToMorse(methodParam);
// assert
expect(result).toBe("... --- ... ");
});
test("Returns a defined string when can't find a translation for the input", () => {
// arrange
const methodParam = "_";
const definedString = "(Can't find this one😬)";
// act
const result = translateStringToMorse(methodParam);
// assert
expect(result).toBe(definedString);
});
});