-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Cody Dalton
committed
Apr 24, 2021
1 parent
72b596a
commit ad986c2
Showing
6 changed files
with
1,858 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# dependencies | ||
/node_modules | ||
|
||
# reports | ||
/coverage | ||
/.nyc_output | ||
|
||
# distributions | ||
/dist | ||
|
||
# system files | ||
.DS_Store | ||
|
||
/.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
full-trace: true | ||
spec: '**/*.spec.js' | ||
bail: true | ||
slow: 2000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const { expect } = require('chai'); | ||
const { Enigma } = require('./enigma'); | ||
|
||
describe('Class: Enigma', () => { | ||
|
||
it('should correctly encrypt a string', () => { | ||
|
||
const encrypted = 'FLYANJAHZGWMQNZQOJYRUGBZJGG'; | ||
const decrypted = 'hi this is an encrypted sentence'; | ||
|
||
const aEnigma = new Enigma([ 5, 10, 9 ], 'ea bc df hi km zt xp ln'); | ||
|
||
expect(aEnigma.encrypt(decrypted)).to.equal(encrypted); | ||
}); | ||
|
||
it('should correctly decrypt a string', () => { | ||
|
||
const encrypted = 'FLYANJAHZGWMQNZQOJYRUGBZJGG'; | ||
const decrypted = 'HITHISISANENCRYPTEDSENTENCE'; | ||
|
||
const aEnigma = new Enigma([ 5, 10, 9 ], 'ea bc df hi km zt xp ln'); | ||
|
||
expect(aEnigma.encrypt(encrypted)).to.equal(decrypted); | ||
}); | ||
|
||
it('should default rotor settings to [0, 0, 0]', () => { | ||
const aEnigma = new Enigma(); | ||
|
||
expect(aEnigma.rotorSettings).to.deep.equal([0, 0, 0]); | ||
}); | ||
|
||
it('should roll over max rotors to [0, 0, 1]', () => { | ||
const aEnigma = new Enigma([ 25, 25, 25 ], 'ea bc df hi km zt xp ln'); | ||
|
||
aEnigma.encrypt('A'); | ||
|
||
expect(aEnigma.rotorSettings).to.deep.equal([0, 0, 0]); | ||
}); | ||
}); |
Oops, something went wrong.