Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Commit 8e32af0

Browse files
committed
1 parent b4aa880 commit 8e32af0

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

src/simpleEncryption.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//Taken from https://www.codewars.com/kata/simple-encryption-number-1-alternating-split/javascript
2+
function encrypt(text, n) {
3+
4+
}
5+
6+
function decrypt(encryptedText, n) {
7+
}
8+
9+
module.exports = {
10+
decrypt,
11+
encrypt,
12+
}

src/simpleEncryption.test.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const test = require('tape')
2+
const { decrypt, encrypt } = require('./simpleEncryption')
3+
4+
test('Solution', function(t) {
5+
t.test('EncryptExampleTests', function(assert) {
6+
assert.equals(encrypt('This is a test!', 0), 'This is a test!')
7+
assert.equals(encrypt('This is a test!', 1), 'hsi etTi sats!')
8+
assert.equals(encrypt('This is a test!', 2), 's eT ashi tist!')
9+
assert.equals(encrypt('This is a test!', 3), ' Tah itse sits!')
10+
assert.equals(encrypt('This is a test!', 4), 'This is a test!')
11+
assert.equals(encrypt('This is a test!', -1), 'This is a test!')
12+
assert.equals(
13+
encrypt('This kata is very interesting!', 1),
14+
'hskt svr neetn!Ti aai eyitrsig'
15+
)
16+
assert.end()
17+
})
18+
})
19+
20+
test('Solution', function(t) {
21+
t.test('DecryptExampleTests', function(assert) {
22+
assert.equals(decrypt('This is a test!', 0), 'This is a test!')
23+
assert.equals(
24+
decrypt('hsi etTi sats!', 1),
25+
'This is a test!',
26+
'1 step decryption'
27+
)
28+
assert.equals(
29+
decrypt('s eT ashi tist!', 2),
30+
'This is a test!',
31+
'Two step decryption'
32+
)
33+
assert.equals(decrypt(' Tah itse sits!', 3), 'This is a test!')
34+
assert.equals(decrypt('This is a test!', 4), 'This is a test!')
35+
assert.equals(decrypt('This is a test!', -1), 'This is a test!')
36+
assert.equals(
37+
decrypt('hskt svr neetn!Ti aai eyitrsig', 1),
38+
'This kata is very interesting!'
39+
)
40+
assert.end()
41+
})
42+
})
43+
44+
test('Solution', function(t) {
45+
t.test('Null or Empty', function(assert) {
46+
assert.equals(encrypt('', 0), '')
47+
assert.equals(decrypt('', 0), '')
48+
assert.equals(encrypt(null, 0), null)
49+
assert.equals(decrypt(null, 0), null)
50+
assert.end()
51+
})
52+
})

0 commit comments

Comments
 (0)