aboutsummaryrefslogtreecommitdiffstats
path: root/backend/node_modules/side-channel/test
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2023-11-04 21:28:11 +0000
committerLeonardo Bishop <me@leonardobishop.com>2023-11-04 21:28:11 +0000
commit7d8cca54e548d2a85287fd2325db88f2697be55a (patch)
tree3daa82c6a709363f2f08d9f875d849e4babe1f8f /backend/node_modules/side-channel/test
parente1633f3348ff7fc5e9131eeae2f2feba09f04838 (diff)
Add more shit
Diffstat (limited to 'backend/node_modules/side-channel/test')
-rw-r--r--backend/node_modules/side-channel/test/index.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/backend/node_modules/side-channel/test/index.js b/backend/node_modules/side-channel/test/index.js
new file mode 100644
index 0000000..3b92ef7
--- /dev/null
+++ b/backend/node_modules/side-channel/test/index.js
@@ -0,0 +1,78 @@
+'use strict';
+
+var test = require('tape');
+
+var getSideChannel = require('../');
+
+test('export', function (t) {
+ t.equal(typeof getSideChannel, 'function', 'is a function');
+ t.equal(getSideChannel.length, 0, 'takes no arguments');
+
+ var channel = getSideChannel();
+ t.ok(channel, 'is truthy');
+ t.equal(typeof channel, 'object', 'is an object');
+
+ t.end();
+});
+
+test('assert', function (t) {
+ var channel = getSideChannel();
+ t['throws'](
+ function () { channel.assert({}); },
+ TypeError,
+ 'nonexistent value throws'
+ );
+
+ var o = {};
+ channel.set(o, 'data');
+ t.doesNotThrow(function () { channel.assert(o); }, 'existent value noops');
+
+ t.end();
+});
+
+test('has', function (t) {
+ var channel = getSideChannel();
+ var o = [];
+
+ t.equal(channel.has(o), false, 'nonexistent value yields false');
+
+ channel.set(o, 'foo');
+ t.equal(channel.has(o), true, 'existent value yields true');
+
+ t.end();
+});
+
+test('get', function (t) {
+ var channel = getSideChannel();
+ var o = {};
+ t.equal(channel.get(o), undefined, 'nonexistent value yields undefined');
+
+ var data = {};
+ channel.set(o, data);
+ t.equal(channel.get(o), data, '"get" yields data set by "set"');
+
+ t.end();
+});
+
+test('set', function (t) {
+ var channel = getSideChannel();
+ var o = function () {};
+ t.equal(channel.get(o), undefined, 'value not set');
+
+ channel.set(o, 42);
+ t.equal(channel.get(o), 42, 'value was set');
+
+ channel.set(o, Infinity);
+ t.equal(channel.get(o), Infinity, 'value was set again');
+
+ var o2 = {};
+ channel.set(o2, 17);
+ t.equal(channel.get(o), Infinity, 'o is not modified');
+ t.equal(channel.get(o2), 17, 'o2 is set');
+
+ channel.set(o, 14);
+ t.equal(channel.get(o), 14, 'o is modified');
+ t.equal(channel.get(o2), 17, 'o2 is not modified');
+
+ t.end();
+});