diff --git a/test/unit/ClientTest.js b/test/unit/ClientTest.js new file mode 100644 index 0000000..dd1a1ea --- /dev/null +++ b/test/unit/ClientTest.js @@ -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('./'), + }))); + }); +});