From f587f5c7ff5dfb01d25de6d43a06d4b47d5b8975 Mon Sep 17 00:00:00 2001
From: librelois <elois@ifee.fr>
Date: Tue, 24 Apr 2018 16:27:59 +0200
Subject: [PATCH] [tests] add paths tests

---
 tests/paths.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 tests/paths.js

diff --git a/tests/paths.js b/tests/paths.js
new file mode 100644
index 0000000..30183af
--- /dev/null
+++ b/tests/paths.js
@@ -0,0 +1,48 @@
+"use strict";
+
+const addon = require('./../lib/index');
+const assert = require('assert');
+const should = require('should');
+
+let baseInstance
+
+describe('Testing getPaths()', function() {
+
+  this.timeout(10000) // 10 seconds max for a test
+
+  before(() => {
+    baseInstance = addon.newMemoryInstance(3)
+    baseInstance.addNode()
+    baseInstance.addNode()
+    baseInstance.addNode()
+    baseInstance.addNode()
+    baseInstance.addLink(0, 1)
+    baseInstance.addLink(1, 2)
+    baseInstance.addLink(2, 3)
+    baseInstance.addLink(0, 3)
+    /**
+     * Wot:
+     *
+     *   0 --> 1 --> 2 --> 3
+     *    `----------------^
+     */
+  })
+
+  it('wotb.getPaths() should return arrays with the size of the paths', () => {
+
+    // Path 0 --> 1
+    assert.equal(baseInstance.getPaths(0, 1, 1).length, 1);
+    assert.equal(baseInstance.getPaths(0, 1, 1)[0].length, 2); // 0, 1
+
+    // Path 0 --> 2
+    assert.equal(baseInstance.getPaths(0, 2, 1).length, 0);
+    assert.equal(baseInstance.getPaths(0, 2, 2).length, 1);
+    assert.equal(baseInstance.getPaths(0, 2, 2)[0].length, 3); // 0, 1, 2
+
+    // Path 0 --> 3
+    assert.equal(baseInstance.getPaths(0, 3, 1).length, 1);
+    assert.equal(baseInstance.getPaths(0, 3, 1)[0].length, 2);
+    assert.equal(baseInstance.getPaths(0, 3, 2).length, 1);
+    assert.equal(baseInstance.getPaths(0, 3, 2)[0].length, 2);
+  })
+})
-- 
GitLab