0
mirror of https://github.com/valentineus/iii-client.git synced 2025-04-29 01:51:24 +03:00

Simple tests have been added

This commit is contained in:
Valentin Popov 2017-09-28 23:10:53 +04:00
parent ba42758715
commit b75c1114c3
2 changed files with 46 additions and 1 deletions

View File

@ -28,7 +28,9 @@
"babel-core": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2015-rollup": "^3.0.0",
"chai": "^4.1.2",
"eslint": "^3.19.0",
"mocha": "^3.5.3",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-node-builtins": "^2.1.2",
@ -38,6 +40,7 @@
"build-standalone": "babel src/index.js --out-file dist/standalone.js",
"build-browser": "rollup --config rollup.config.js",
"build": "npm run build-browser && npm run build-standalone",
"check": "eslint ./src/*"
"test": "mocha src/test.js --compilers js:babel-core/register",
"check": "eslint ./src/index.js"
}
}

42
src/test.js Normal file
View File

@ -0,0 +1,42 @@
import { assert } from 'chai';
import {
decryptJSON,
connect,
decrypt,
encrypt,
send
} from './index';
describe('iii-client:', () => {
var uuid = '109cd867-0ef3-4473-af71-7543a9b2fccd';
var cuid = '0340feab-b09e-4960-96e9-c9518b1fb157';
var text = 'Hello, World!';
var data = JSON.stringify({ text });
it('encrypt():', () => {
assert.notEqual(text, encrypt(text));
});
it('decrypt():', () => {
var encrypted = encrypt(text);
assert.equal(text, decrypt(encrypted));
});
it('decryptJSON():', () => {
var encrypted = encrypt(data);
assert.equal(data, decrypt(encrypted).toString());
});
it('connect():', () => {
connect(uuid, (request) => {
assert.isObject(request);
});
});
it('send():', () => {
send(cuid, text, (request) => {
assert.isObject(request);
});
});
});