From 3685913bf510a14b8cb324d980217d90489e6453 Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Wed, 25 Apr 2018 19:45:39 +0200 Subject: js: First testing and improvements -- * Introduced Mocha/chai as testsuite. After development build 'npm test' should run the unit tests. Functionality exclusive to Browsers/WebExtensions cannot be run this way, so some other testing is still needed. - package.json: Added required development packages - .babelrc indirect configuration for mocha. ES6 transpiling needs some babel configuration, but mocha has no setting for it. - test/mocha.opts Vonfiguration for mocha runs * Fixed errors: - Helpers.js toKeyIdArray; isLongId is now exported - Key.js Key constructor failed - Message.js will not throw an Error during construction, a new message is now created with createMessage, which can return an Error or a GPGME_Message object * Tests: - test/Helpers: exports from Helpers.js, GPGME_Error handling - test/Message: first init test with bad parameters --- lang/js/src/Keyring.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lang/js/src/Keyring.js') diff --git a/lang/js/src/Keyring.js b/lang/js/src/Keyring.js index e1f0a50f..470eeeec 100644 --- a/lang/js/src/Keyring.js +++ b/lang/js/src/Keyring.js @@ -18,7 +18,7 @@ * SPDX-License-Identifier: LGPL-2.1+ */ -import {GPGME_Message} from './Message' +import {createMessage} from './Message' import {GPGME_Key} from './Key' import { isFingerprint, isLongId } from './Helpers'; import { gpgme_error } from './Errors'; @@ -50,7 +50,10 @@ export class GPGME_Keyring { * */ getKeys(pattern, include_secret){ - let msg = new GPGME_Message('listkeys'); + let msg = createMessage('listkeys'); + if (msg instanceof Error){ + return Promise.reject(msg); + } if (pattern && typeof(pattern) === 'string'){ msg.setParameter('pattern', pattern); } -- cgit v1.2.3