Repository navigation
Expand file tree
/
Copy pathcaesarCipher.test.js
More file actions
93 lines (80 loc) · 2.84 KB
/
Copy pathcaesarCipher.test.js
File metadata and controls
93 lines (80 loc) · 2.84 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import {displayPerfTime} from '../../../utils/perf-utils';
import {
caesarCipher,
caesarCipher2,
caesarCipher3,
caesarCipher4,
} from '../caesarCipher';
describe('Caesar Cipher', () => {
it('should encrypt zoo keeper', () => {
expect(caesarCipher('Zoo keeper', 2)).toEqual('Bqq mggrgt');
});
it('should encryp Big Cart', () => {
expect(caesarCipher('Big Car', -16)).toEqual('Lsq Mkb');
});
it('should encrypt zoo keeper with second approach', () => {
expect(caesarCipher2('Zoo keeper', 2)).toEqual('Bqq mggrgt');
});
it('should encrypt Big Car with second approach', () => {
expect(caesarCipher2('Big Car', -16)).toEqual('Lsq Mkb');
});
it('should encrypt zoo keeper with third approach', () => {
expect(caesarCipher3('Zoo keeper', 2)).toEqual('Bqq mggrgt');
});
it('should encrypt Big Car with third approach', () => {
expect(caesarCipher3('Big Car', -16)).toEqual('Lsq Mkb');
});
it('should encrypt zoo keeper with fourth approach', () => {
expect(caesarCipher4('Zoo keeper', 2)).toEqual('Bqq mggrgt');
});
// caesarCipher4 does not manage negative num
// it('should encrypt Big Car with fourth approach', () => {
// expect(caesarCipher4('Big Car', -16)).toEqual('Lsq Mkb')
// })
describe('Performance', () => {
it('will display perftime', () => {
displayPerfTime("caesarCipher('a string', 1)", () => {
caesarCipher('a string', 1);
});
displayPerfTime("caesarCipher('long string', 1)", () => {
caesarCipher(
'a long string to test Caesar Cipher a long string to test Caesar Cipher a long string to test Caesar Cipher',
1
);
});
});
it('will display perftime', () => {
displayPerfTime("caesarCipher2('a string', 1)", () => {
caesarCipher2('a string', 1);
});
displayPerfTime("caesarCipher2('long string', 1)", () => {
caesarCipher2(
'a long string to test Caesar Cipher a long string to test Caesar Cipher a long string to test Caesar Cipher',
1
);
});
});
it('will display perftime', () => {
displayPerfTime("caesarCipher3('a string', 1)", () => {
caesarCipher3('a string', 1);
});
displayPerfTime("caesarCipher3('long string', 1)", () => {
caesarCipher3(
'a long string to test Caesar Cipher a long string to test Caesar Cipher a long string to test Caesar Cipher',
1
);
});
});
it('will display perftime', () => {
displayPerfTime("caesarCipher4('a string', 1)", () => {
caesarCipher4('a string', 1);
});
displayPerfTime("caesarCipher4('long string', 1)", () => {
caesarCipher4(
'a long string to test Caesar Cipher a long string to test Caesar Cipher a long string to test Caesar Cipher',
1
);
});
});
});
});