-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrypto-square.spec.js
53 lines (43 loc) · 1.67 KB
/
crypto-square.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
import { Crypto } from './crypto-square';
describe('Crypto', () => {
test('normalize strange characters', () => {
const crypto = new Crypto('s#$%^&plunk');
expect(crypto.normalizePlaintext()).toEqual('splunk');
});
test('normalize numbers', () => {
const crypto = new Crypto('1, 2, 3 GO!');
expect(crypto.normalizePlaintext()).toEqual('123go');
});
test('size of small square', () => {
const crypto = new Crypto('1234');
expect(crypto.size()).toEqual(2);
});
test('size of small square with additional non-number chars', () => {
const crypto = new Crypto('1 2 3 4');
expect(crypto.size()).toEqual(2);
});
test('size of slightly larger square', () => {
const crypto = new Crypto('123456789');
expect(crypto.size()).toEqual(3);
});
test('size of non-perfect square', () => {
const crypto = new Crypto('123456789abc');
expect(crypto.size()).toEqual(4);
});
test('plain text segments', () => {
const crypto = new Crypto('Never vex thine heart with idle woes');
expect(crypto.plaintextSegments()).toEqual(['neverv', 'exthin', 'eheart', 'withid', 'lewoes']);
});
test('plain text segments', () => {
const crypto = new Crypto('ZOMG! ZOMBIES!!!');
expect(crypto.plaintextSegments()).toEqual(['zomg', 'zomb', 'ies']);
});
test('cipher text', () => {
const crypto = new Crypto('Time is an illusion. Lunchtime doubly so.');
expect(crypto.ciphertext()).toEqual('tasneyinicdsmiohooelntuillibsuuml');
});
test('cipher text', () => {
const crypto = new Crypto('We all know interspecies romance is weird.');
expect(crypto.ciphertext()).toEqual('wneiaweoreneawssciliprerlneoidktcms');
});
});