bob/bob.spec.js   A
last analyzed

Complexity

Total Complexity 26
Complexity/F 1

Size

Lines of Code 128
Function Count 26

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 26
eloc 77
mnd 0
bc 0
fnc 26
dl 0
loc 128
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10
1
import { hey } from "./bob";
2
3
describe("Bob", () => {
4
  test("stating something", () => {
5
    const result = hey("Tom-ay-to, tom-aaaah-to.");
6
    expect(result).toEqual("Whatever.");
7
  });
8
9
  test("shouting", () => {
10
    const result = hey("WATCH OUT!");
11
    expect(result).toEqual("Whoa, chill out!");
12
  });
13
14
  test("shouting gibberish", () => {
15
    const result = hey("FCECDFCAAB");
16
    expect(result).toEqual("Whoa, chill out!");
17
  });
18
19
  test("asking a question", () => {
20
    const result = hey("Does this cryogenic chamber make me look fat?");
21
    expect(result).toEqual("Sure.");
22
  });
23
24
  test("asking a numeric question", () => {
25
    const result = hey("You are, what, like 15?");
26
    expect(result).toEqual("Sure.");
27
  });
28
29
  test("asking gibberish", () => {
30
    const result = hey("fffbbcbeab?");
31
    expect(result).toEqual("Sure.");
32
  });
33
34
  test("talking forcefully", () => {
35
    const result = hey("Let's go make out behind the gym!");
36
    expect(result).toEqual("Whatever.");
37
  });
38
39
  test("using acronyms in regular speech", () => {
40
    const result = hey("It's OK if you don't want to go to the DMV.");
41
    expect(result).toEqual("Whatever.");
42
  });
43
44
  test("forceful question", () => {
45
    const result = hey("WHAT THE HELL WERE YOU THINKING?");
46
    expect(result).toEqual("Calm down, I know what I'm doing!");
47
  });
48
49
  test("shouting numbers", () => {
50
    const result = hey("1, 2, 3 GO!");
51
    expect(result).toEqual("Whoa, chill out!");
52
  });
53
54
  test("only numbers", () => {
55
    const result = hey("1, 2, 3");
56
    expect(result).toEqual("Whatever.");
57
  });
58
59
  test("question with only numbers", () => {
60
    const result = hey("4?");
61
    expect(result).toEqual("Sure.");
62
  });
63
64
  test("shouting with special characters", () => {
65
    const result = hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!");
66
    expect(result).toEqual("Whoa, chill out!");
67
  });
68
69
  test("shouting with no exclamation mark", () => {
70
    const result = hey("I HATE YOU");
71
    expect(result).toEqual("Whoa, chill out!");
72
  });
73
74
  test("statement containing question mark", () => {
75
    const result = hey("Ending with a ? means a question.");
76
    expect(result).toEqual("Whatever.");
77
  });
78
79
  test("non-letters with question", () => {
80
    const result = hey(":) ?");
81
    expect(result).toEqual("Sure.");
82
  });
83
84
  test("prattling on", () => {
85
    const result = hey("Wait! Hang on. Are you going to be OK?");
86
    expect(result).toEqual("Sure.");
87
  });
88
89
  test("silence", () => {
90
    const result = hey("");
91
    expect(result).toEqual("Fine. Be that way!");
92
  });
93
94
  test("prolonged silence", () => {
95
    const result = hey("          ");
96
    expect(result).toEqual("Fine. Be that way!");
97
  });
98
99
  test("alternate silence", () => {
100
    const result = hey("\t\t\t\t\t\t\t\t\t\t");
101
    expect(result).toEqual("Fine. Be that way!");
102
  });
103
104
  test("multiple line question", () => {
105
    const result = hey("\nDoes this cryogenic chamber make me look fat?\nno");
106
    expect(result).toEqual("Whatever.");
107
  });
108
109
  test("starting with whitespace", () => {
110
    const result = hey("         hmmmmmmm...");
111
    expect(result).toEqual("Whatever.");
112
  });
113
114
  test("ending with whitespace", () => {
115
    const result = hey("Okay if like my  spacebar  quite a bit?   ");
116
    expect(result).toEqual("Sure.");
117
  });
118
119
  test("other whitespace", () => {
120
    const result = hey("\n\r \t");
121
    expect(result).toEqual("Fine. Be that way!");
122
  });
123
124
  test("non-question ending with whitespace", () => {
125
    const result = hey("This is a statement ending with whitespace      ");
126
    expect(result).toEqual("Whatever.");
127
  });
128
});
129