-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathstrings.test.js
64 lines (55 loc) · 1.76 KB
/
strings.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
53
54
55
56
57
58
59
60
61
62
63
64
const {
sayHello,
uppercase,
lowercase,
countCharacters,
firstCharacter,
firstCharacters
} = require('../strings');
describe('sayHello', () => {
it('returns "Hello world!" when passed "world"', () => {
expect(sayHello('world')).toEqual('Hello, world!');
});
it('returns "Hello MCR Codes!" when passed "MCR Codes"', () => {
expect(sayHello('MCR Codes')).toEqual('Hello, MCR Codes!');
});
it('returns "Hello fsghjdfkhgf!" when passed "fsghjdfkhgf"', () => {
expect(sayHello('fsghjdfkhgf')).toEqual('Hello, fsghjdfkhgf!');
});
});
describe('uppercase', () => {
it('returns the uppercased string', () => {
expect(uppercase('abc')).toEqual('ABC');
expect(uppercase('def')).toEqual('DEF');
expect(uppercase('ghi')).toEqual('GHI');
});
});
describe('lowercase', () => {
it('returns the lowercased string', () => {
expect(lowercase('ABC')).toEqual('abc');
expect(lowercase('DEF')).toEqual('def');
expect(lowercase('GHI')).toEqual('ghi');
});
});
describe('countCharacters', () => {
it('returns the number of characters in the string', () => {
expect(countCharacters('fsfsgsfdg')).toEqual(9);
expect(countCharacters('fsfsg')).toEqual(5);
expect(countCharacters('')).toEqual(0);
});
});
describe('firstCharacter', () => {
it('returns the first character of the string', () => {
expect(firstCharacter('ABC')).toEqual('A');
expect(firstCharacter('DEF')).toEqual('D');
expect(firstCharacter('GHI')).toEqual('G');
});
});
describe('firstCharacters', () => {
it('returns the first 4 characters of the string', () => {
expect(firstCharacters('sd32fg45', 4)).toEqual('sd32');
});
it('returns the first 2 characters of the string', () => {
expect(firstCharacters('asd', 2)).toEqual('as');
});
});