|
| 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