From c41fcdc269d4ed599ea8d46b73d409d641111b4a Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Wed, 15 Sep 2010 09:42:28 -0700 Subject: [PATCH] Started tests with utils.base64 --- .gitmodules | 3 +++ Makefile | 6 ++++++ lib/ns3.js | 7 ------- lib/ns3/auth.js | 13 +++++++++++++ lib/ns3/index.js | 22 ++++++++++++++++++++++ lib/ns3/utils.js | 22 ++++++++++++++++++++++ support/expresso | 1 + test/ns3.test.js | 12 ++++++++++++ test/utils.test.js | 17 +++++++++++++++++ 9 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 .gitmodules delete mode 100644 lib/ns3.js create mode 100644 lib/ns3/auth.js create mode 100644 lib/ns3/index.js create mode 100644 lib/ns3/utils.js create mode 160000 support/expresso create mode 100644 test/utils.test.js diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ffe0dcb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "support/expresso"] + path = support/expresso + url = git://github.com/visionmedia/expresso.git diff --git a/Makefile b/Makefile index e69de29..8efcc7f 100644 --- a/Makefile +++ b/Makefile @@ -0,0 +1,6 @@ + +test: + @./support/expresso/bin/expresso test/*.test.js \ + -I lib + +.PHONY: test \ No newline at end of file diff --git a/lib/ns3.js b/lib/ns3.js deleted file mode 100644 index 41a659c..0000000 --- a/lib/ns3.js +++ /dev/null @@ -1,7 +0,0 @@ - -/*! - * ns3 - * Copyright(c) 2010 LearnBoost - * MIT Licensed - */ - diff --git a/lib/ns3/auth.js b/lib/ns3/auth.js new file mode 100644 index 0000000..207c333 --- /dev/null +++ b/lib/ns3/auth.js @@ -0,0 +1,13 @@ + +/*! + * ns3 - auth + * Copyright(c) 2010 LearnBoost + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var http = require('http') + , fs = require('fs'); \ No newline at end of file diff --git a/lib/ns3/index.js b/lib/ns3/index.js new file mode 100644 index 0000000..6726408 --- /dev/null +++ b/lib/ns3/index.js @@ -0,0 +1,22 @@ + +/*! + * ns3 + * Copyright(c) 2010 LearnBoost + * MIT Licensed + */ + +/** + * Library version. + * + * @type String + */ + +exports.version = '0.0.1'; + +/** + * Expose utilities. + * + * @type Object + */ + +exports.utils = require('./utils'); \ No newline at end of file diff --git a/lib/ns3/utils.js b/lib/ns3/utils.js new file mode 100644 index 0000000..48743f6 --- /dev/null +++ b/lib/ns3/utils.js @@ -0,0 +1,22 @@ + +/*! + * ns3 - utils + * Copyright(c) 2010 LearnBoost + * MIT Licensed + */ + +/** + * Module dependencies. + */ + +var crypto = require('crypto'); + +exports.base64 = { + encode: function(str){ + return new Buffer(str).toString('base64'); + }, + + decode: function(str){ + return new Buffer(str, 'base64').toString(); + } +}; \ No newline at end of file diff --git a/support/expresso b/support/expresso new file mode 160000 index 0000000..d05bb65 --- /dev/null +++ b/support/expresso @@ -0,0 +1 @@ +Subproject commit d05bb65b69c80a7e11ce9953489dc742ac25c9ce diff --git a/test/ns3.test.js b/test/ns3.test.js index e69de29..a4f4dc1 100644 --- a/test/ns3.test.js +++ b/test/ns3.test.js @@ -0,0 +1,12 @@ + +/** + * Module dependencies. + */ + +var ns3 = require('ns3'); + +module.exports = { + 'test .version': function(assert){ + assert.match(ns3.version, /^\d+\.\d+\.\d+$/); + } +}; \ No newline at end of file diff --git a/test/utils.test.js b/test/utils.test.js new file mode 100644 index 0000000..9521498 --- /dev/null +++ b/test/utils.test.js @@ -0,0 +1,17 @@ + +/** + * Module dependencies. + */ + +var ns3 = require('ns3') + , utils = ns3.utils; + +module.exports = { + 'test .base64.encode()': function(assert){ + assert.equal('aGV5', utils.base64.encode('hey')); + }, + + 'test .base64.decode()': function(assert){ + assert.equal('hey', utils.base64.decode('aGV5')); + } +};