-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcipher.spec.js
37 lines (30 loc) · 954 Bytes
/
cipher.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
import fs from "fs";
import {Tokenizer} from "./tokenizer";
import {assert} from 'chai';
import {CaesarCipher} from '../target/cipher';
describe("Q5", () => {
it("test1", () => {
const cipher = new CaesarCipher(5);
var ret = cipher.encrypt("hello world!");
assert.equal(ret , "mjqqt btwqi!");
});
it("test2", () => {
const cipher = new CaesarCipher(5);
var ret = cipher.decrypt("mjqqt btwqi!");
assert.equal(ret , "hello world!");
});
it("test3", () => {
const cipher = new CaesarCipher(26);
var ret = cipher.encrypt("hello world!");
assert.equal(ret , "hello world!");
});
it("test4", () => {
const cipher = new CaesarCipher(26);
var ret = cipher.decrypt("hello world!");
assert.equal(ret , "hello world!");
});
it("not use `for`", () => {
var str = fs.readFileSync("es6/src/cipher.js", "utf-8");
assert.notOk(new Tokenizer().split(str).some(v => v === "for"));
});
});