[Pkg-javascript-commits] [node-umd] 09/11: Add really basic tests

Bastien Roucariès rouca at moszumanska.debian.org
Mon Apr 17 07:38:07 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to annotated tag 1.3.0
in repository node-umd.

commit e6d7a932bb3586504fb9b86953dc94fc9233020f
Author: ForbesLindesay <forbes at lindesay.co.uk>
Date:   Thu Aug 1 18:28:03 2013 +0100

    Add really basic tests
---
 package.json  |  7 ++++---
 test/index.js | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/package.json b/package.json
index 622188f..15b6da1 100644
--- a/package.json
+++ b/package.json
@@ -10,10 +10,11 @@
     "uglify-js": "~2.3.6"
   },
   "devDependencies": {
-    "linify": "~1.0.1"
+    "linify": "~1.0.1",
+    "mocha": "*"
   },
   "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1",
+    "test": "mocha -R spec",
     "prepublish": "linify transform bin"
   },
   "repository": {
@@ -22,4 +23,4 @@
   },
   "author": "ForbesLindesay",
   "license": "MIT"
-}
\ No newline at end of file
+}
diff --git a/test/index.js b/test/index.js
new file mode 100644
index 0000000..3e2d943
--- /dev/null
+++ b/test/index.js
@@ -0,0 +1,39 @@
+var assert = require('assert')
+var umd = require('../')
+var src = umd('sentinel-prime', 'return "sentinel"')
+
+describe('with CommonJS', function () {
+  it('uses module.exports', function () {
+    var module = {exports: {}}
+    Function('module,exports', src)(module,module.exports)
+    assert(module.exports === 'sentinel')
+  })
+})
+describe('with amd', function () {
+  it('uses define', function () {
+    var defed
+    function define(fn) {
+      defed = fn()
+    }
+    define.amd = true
+    Function('define', src)(define)
+    assert(defed === 'sentinel')
+  })
+})
+describe('in the absense of a module system', function () {
+  it('uses window', function () {
+    var glob = {}
+    Function('window', src)(glob)
+    assert(glob.sentinelPrime === 'sentinel')
+  })
+  it('uses global', function () {
+    var glob = {}
+    Function('global,window', src)(glob)
+    assert(glob.sentinelPrime === 'sentinel')
+  })
+  it('uses self', function () {
+    var glob = {}
+    Function('self,window,global', src)(glob)
+    assert(glob.sentinelPrime === 'sentinel')
+  })
+})
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-umd.git



More information about the Pkg-javascript-commits mailing list