aboutsummaryrefslogtreecommitdiffstats
path: root/library/sodium-plus/test/async-helper.js
diff options
context:
space:
mode:
Diffstat (limited to 'library/sodium-plus/test/async-helper.js')
-rw-r--r--library/sodium-plus/test/async-helper.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/library/sodium-plus/test/async-helper.js b/library/sodium-plus/test/async-helper.js
new file mode 100644
index 000000000..d3b5ebc00
--- /dev/null
+++ b/library/sodium-plus/test/async-helper.js
@@ -0,0 +1,13 @@
+const { expect } = require('chai');
+module.exports = async function expectError(promised, message) {
+ let thrown = false;
+ try {
+ await promised;
+ } catch (e) {
+ thrown = true;
+ expect(message).to.be.equal(e.message);
+ }
+ if (!thrown) {
+ throw new Error('Function did not throw');
+ }
+};