[Pkg-javascript-commits] [node-module-deps] 91/444: Add test case for transforming all files within a package.

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:47:46 UTC 2017


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

rouca pushed a commit to branch master
in repository node-module-deps.

commit 20e9de243aceabb9fdd4ee85b2859b17fdd9d5ad
Author: Jared Hanson <jaredhanson at gmail.com>
Date:   Sat Jun 8 15:25:56 2013 -0700

    Add test case for transforming all files within a package.
---
 test/files/tr_whole_package/f.js                                   | 3 +++
 test/files/tr_whole_package/main.js                                | 3 +++
 test/files/tr_whole_package/node_modules/algo/index.js             | 3 +++
 test/files/tr_whole_package/node_modules/algo/lib/decrement.js     | 1 +
 .../node_modules/algo/node_modules/insert-ggg/index.js             | 7 +++++++
 test/files/tr_whole_package/node_modules/algo/package.json         | 6 ++++++
 test/tr_2dep_module.js                                             | 2 --
 test/{tr_2dep_module.js => tr_whole_package.js}                    | 7 ++-----
 8 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/test/files/tr_whole_package/f.js b/test/files/tr_whole_package/f.js
new file mode 100644
index 0000000..39d983d
--- /dev/null
+++ b/test/files/tr_whole_package/f.js
@@ -0,0 +1,3 @@
+var calc = require('algo').calc;
+
+module.exports = function (x) { return calc(x); }
diff --git a/test/files/tr_whole_package/main.js b/test/files/tr_whole_package/main.js
new file mode 100644
index 0000000..5b61c24
--- /dev/null
+++ b/test/files/tr_whole_package/main.js
@@ -0,0 +1,3 @@
+var f = require('./f.js');
+
+t.equal(f(14), 11, 'transformation scope');
diff --git a/test/files/tr_whole_package/node_modules/algo/index.js b/test/files/tr_whole_package/node_modules/algo/index.js
new file mode 100644
index 0000000..84771c4
--- /dev/null
+++ b/test/files/tr_whole_package/node_modules/algo/index.js
@@ -0,0 +1,3 @@
+var decrement = require('./lib/decrement');
+
+exports.calc = function (x) { return decrement(x) - GGG - GGG }
diff --git a/test/files/tr_whole_package/node_modules/algo/lib/decrement.js b/test/files/tr_whole_package/node_modules/algo/lib/decrement.js
new file mode 100644
index 0000000..6ea84d3
--- /dev/null
+++ b/test/files/tr_whole_package/node_modules/algo/lib/decrement.js
@@ -0,0 +1 @@
+module.exports = function (x) { return x - GGG }
diff --git a/test/files/tr_whole_package/node_modules/algo/node_modules/insert-ggg/index.js b/test/files/tr_whole_package/node_modules/algo/node_modules/insert-ggg/index.js
new file mode 100644
index 0000000..7727f75
--- /dev/null
+++ b/test/files/tr_whole_package/node_modules/algo/node_modules/insert-ggg/index.js
@@ -0,0 +1,7 @@
+var through = require('through');
+
+module.exports = function (file) {
+    return through(function (buf) {
+        this.queue(String(buf).replace(/GGG/g, '1'));
+    });
+};
diff --git a/test/files/tr_whole_package/node_modules/algo/package.json b/test/files/tr_whole_package/node_modules/algo/package.json
new file mode 100644
index 0000000..3a16bd4
--- /dev/null
+++ b/test/files/tr_whole_package/node_modules/algo/package.json
@@ -0,0 +1,6 @@
+{
+  "main": "index.js",
+  "browserify": {
+    "transform": "insert-ggg"
+  }
+}
diff --git a/test/tr_2dep_module.js b/test/tr_2dep_module.js
index 8e6d63e..2af1b8e 100644
--- a/test/tr_2dep_module.js
+++ b/test/tr_2dep_module.js
@@ -16,8 +16,6 @@ test('transform', function (t) {
     var src = '';
     pack.on('data', function (buf) { src += buf });
     pack.on('end', function () {
-        console.error('SOURCE:');
-        console.error(src);
         Function('t', src)(t);
     });
 });
diff --git a/test/tr_2dep_module.js b/test/tr_whole_package.js
similarity index 70%
copy from test/tr_2dep_module.js
copy to test/tr_whole_package.js
index 8e6d63e..92ae647 100644
--- a/test/tr_2dep_module.js
+++ b/test/tr_whole_package.js
@@ -4,9 +4,8 @@ var JSONStream = require('JSONStream');
 var packer = require('browser-pack');
 
 test('transform', function (t) {
-    t.plan(3);
-    var p = mdeps(__dirname + '/files/tr_2dep_module/main.js', {
-        transform: [ 'insert-aaa', 'insert-bbb' ],
+    t.plan(1);
+    var p = mdeps(__dirname + '/files/tr_whole_package/main.js', {
         transformKey: [ 'browserify', 'transform' ]
     });
     var pack = packer();
@@ -16,8 +15,6 @@ test('transform', function (t) {
     var src = '';
     pack.on('data', function (buf) { src += buf });
     pack.on('end', function () {
-        console.error('SOURCE:');
-        console.error(src);
         Function('t', src)(t);
     });
 });

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



More information about the Pkg-javascript-commits mailing list