tests: start Client tests

This commit is contained in:
nanov 2019-11-08 11:24:59 +02:00
parent d482b1dde1
commit 6ecb256483

29
test/unit/ClientTest.js Normal file
View File

@ -0,0 +1,29 @@
'use strict';
/* eslint-env node, mocha */
const { assert } = require('chai');
const { Client, fsKeysStorage, tracesStorage } = require('../../index.js');
describe('Client', () => {
describe('instantiating', () => {
it('should throw with no options provided', () => assert.throws(() => new Client()));
it('should throw with no url provided', () => assert.throws(() => new Client({})));
it('should throw with no partnerId provided', () => assert.throws(() => new Client({ url: 'https://myebics.com' })));
it('should throw with no userId provided', () => assert.throws(() => new Client({ url: 'https://myebics.com', partnerId: 'partnerId' })));
it('should throw with no hostId provided', () => assert.throws(() => new Client({ url: 'https://myebics.com', partnerId: 'partnerId', userId: 'userId' })));
it('should throw with no passphrase provided', () => assert.throws(() => new Client({
url: 'https://myebics.com', partnerId: 'partnerId', userId: 'userId', hostId: 'hostId',
})));
it('should throw with no keyStorage provided', () => assert.throws(() => new Client({
url: 'https://myebics.com', partnerId: 'partnerId', userId: 'userId', hostId: 'hostId', passphrase: 'test',
})));
it('should create an isntance without tracesStorage', () => assert.doesNotThrow(() => new Client({
url: 'https://myebics.com', partnerId: 'partnerId', userId: 'userId', hostId: 'hostId', passphrase: 'test', keyStorage: fsKeysStorage('./test.key'),
})));
it('should create an isntance with tracesStorage', () => assert.doesNotThrow(() => new Client({
url: 'https://myebics.com', partnerId: 'partnerId', userId: 'userId', hostId: 'hostId', passphrase: 'test', keyStorage: fsKeysStorage('./test.key'), tracesStorage: tracesStorage('./'),
})));
});
});