Skip to content

Instantly share code, notes, and snippets.

@hoorayimhelping
Created September 7, 2015 03:36
Show Gist options
  • Save hoorayimhelping/27c6abdc26b6e283713e to your computer and use it in GitHub Desktop.
Save hoorayimhelping/27c6abdc26b6e283713e to your computer and use it in GitHub Desktop.
diff --git a/gulpfile.js b/gulpfile.js
index b166623..fe7ae80 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -5,6 +5,8 @@ var jshint = require('gulp-jshint');
var browserify = require('browserify');
var tape = require('gulp-tape');
+var shell = require('gulp-shell');
+
var paths = {
'js_source': 'js/src/',
'js_test': 'js/test/',
@@ -22,10 +24,9 @@ gulp.task('lint', function() {
.pipe(jshint.reporter('fail'));
});
-gulp.task('test', function() {
- return gulp.src(paths.js_test + '/*.js')
- .pipe(tape());
-});
+gulp.task('test', shell.task([
+ 'tape ' + paths.js_test + '* | faucet',
+]));
gulp.task('build', function() {
return browserify(paths.js_source + 'main.js')
diff --git a/js/src/node.js b/js/src/node.js
new file mode 100644
index 0000000..e1bb5e2
--- /dev/null
+++ b/js/src/node.js
@@ -0,0 +1,18 @@
+var Node = function() {
+ this.id = new Date().getTime();
+ this.neighbors = [];
+};
+
+Node.prototype = {
+ add: function(node) {
+ this.neighbors.push(node);
+ },
+
+ contains: function(node) {
+ return this.neighbors.some(function(current_node) {
+ return current_node.id === node.id;
+ });
+ }
+};
+
+module.exports = Node;
\ No newline at end of file
diff --git a/js/test/graph.js b/js/test/graph.js
index 4541144..2c1786c 100644
--- a/js/test/graph.js
+++ b/js/test/graph.js
@@ -1,6 +1,8 @@
-var tape = require('tape');
+var test = require('tape');
+var Graph = require('../src/graph');
-tape("yeah", function(t) {
+test("adjacency of nodes", function(t) {
+ var graph = new Graph();
t.plan(1);
console.log('leo dicaprio');
diff --git a/js/test/node.js b/js/test/node.js
new file mode 100644
index 0000000..257c5ce
--- /dev/null
+++ b/js/test/node.js
@@ -0,0 +1,23 @@
+var test = require('tape');
+var Node = require('../src/node');
+
+test("adding an adjacent node", function(t) {
+ var node = new Node();
+ node.id = 1;
+
+ t.plan(1);
+
+ node.add({});
+ t.equal(node.neighbors.length, 1);
+
+ t.end();
+});
+
+test("if a node contains another node", function(t) {
+ var node = new Node();
+ t.plan(1);
+
+ t.true(true);
+
+ t.end();
+});
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment