-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrotational-cipher.spec.js
73 lines (53 loc) · 1.89 KB
/
rotational-cipher.spec.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
65
66
67
68
69
70
71
72
73
import { RotationalCipher } from './rotational-cipher';
describe('Rotational cipher', () => {
test('rotate a by 0, same output as input', () => {
const expected = 'a';
const actual = RotationalCipher.rotate('a', 0);
expect(actual).toEqual(expected);
});
test('rotate a by 1', () => {
const expected = 'b';
const actual = RotationalCipher.rotate('a', 1);
expect(actual).toEqual(expected);
});
test('rotate a by 26, same output as input', () => {
const expected = 'a';
const actual = RotationalCipher.rotate('a', 26);
expect(actual).toEqual(expected);
});
test('rotate m by 13', () => {
const expected = 'z';
const actual = RotationalCipher.rotate('m', 13);
expect(actual).toEqual(expected);
});
test('rotate n by 13 with wrap around alphabet', () => {
const expected = 'a';
const actual = RotationalCipher.rotate('n', 13);
expect(actual).toEqual(expected);
});
test('rotate capital letters', () => {
const expected = 'TRL';
const actual = RotationalCipher.rotate('OMG', 5);
expect(actual).toEqual(expected);
});
test('rotate spaces', () => {
const expected = 'T R L';
const actual = RotationalCipher.rotate('O M G', 5);
expect(actual).toEqual(expected);
});
test('rotate numbers', () => {
const expected = 'Xiwxmrk 1 2 3 xiwxmrk';
const actual = RotationalCipher.rotate('Testing 1 2 3 testing', 4);
expect(actual).toEqual(expected);
});
test('rotate punctuation', () => {
const expected = 'Gzo\'n zvo, Bmviyhv!';
const actual = RotationalCipher.rotate('Let\'s eat, Grandma!', 21);
expect(actual).toEqual(expected);
});
test('rotate all letters', () => {
const expected = 'Gur dhvpx oebja sbk whzcf bire gur ynml qbt.';
const actual = RotationalCipher.rotate('The quick brown fox jumps over the lazy dog.', 13);
expect(actual).toEqual(expected);
});
});