[Pkg-javascript-commits] [node-umd] 03/05: Add tests against camel casing and sanitization
Bastien Roucariès
rouca at moszumanska.debian.org
Mon Apr 17 07:38:15 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to tag 3.0.1
in repository node-umd.
commit 20128b98ef297b418bd398814ea01908d2e4af1d
Author: Ben Drucker <bvdrucker at gmail.com>
Date: Sat Apr 25 09:53:50 2015 -0400
Add tests against camel casing and sanitization
---
test/index.js | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/test/index.js b/test/index.js
index 55e7e63..33fca69 100644
--- a/test/index.js
+++ b/test/index.js
@@ -6,7 +6,12 @@ var src = umd('sentinel-prime', 'return "sentinel"')
var namespacedSrc = umd('sentinel.prime', 'return "sentinel"')
var multiNamespaces = umd('a.b.c.d.e', 'return "sentinel"')
var dollared = umd('$', 'return "sentinel"')
+var number = umd('2sentinel', 'return "sentinel"')
+var strip = umd('sentinel^', 'return "sentinel"')
+it('throws when no valid identifier is produced', function () {
+ assert.throws(umd.bind(null, '^!', ''), /Invalid JavaScript/)
+})
describe('with CommonJS', function () {
it('uses module.exports', function () {
var module = {exports: {}}
@@ -62,4 +67,19 @@ describe('in the absense of a module system', function () {
Function('window', dollared)(glob)
assert(glob.$ === 'sentinel')
})
+ it('camelCases the name', function () {
+ var glob = {}
+ Function('window', src)(glob)
+ assert(glob.sentinelPrime === 'sentinel')
+ })
+ it('strips invalid leading characters', function () {
+ var glob = {}
+ Function('window', number)(glob)
+ assert(glob.sentinel === 'sentinel')
+ })
+ it('removes invalid characters', function () {
+ var glob = {}
+ Function('window', strip)(glob)
+ assert(glob.sentinel === 'sentinel')
+ })
})
--
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