From 6ecb256483dbdf7474625f1ce5185dc8e83ea928 Mon Sep 17 00:00:00 2001 From: nanov Date: Fri, 8 Nov 2019 11:24:59 +0200 Subject: [PATCH] tests: start Client tests --- test/unit/ClientTest.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/unit/ClientTest.js 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('./'), + }))); + }); +});