[Pkg-javascript-commits] [node-module-deps] 04/444: passing test

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:47:38 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 482ee95ddc2b9abeba7700f21c4cf5e7a08ba850
Author: James Halliday <mail at substack.net>
Date:   Mon Feb 11 06:44:14 2013 -0800

    passing test
---
 example/files/bar.js           |  2 --
 test/deps.js                   | 42 ++++++++++++++++++++++++++++++++++++++++++
 {example => test}/files/bar.js |  2 --
 test/files/foo.js              |  5 +++++
 test/files/main.js             |  2 ++
 test/files/xyz.js              |  2 ++
 6 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/example/files/bar.js b/example/files/bar.js
index 356a3ae..c57fa53 100644
--- a/example/files/bar.js
+++ b/example/files/bar.js
@@ -1,5 +1,3 @@
-var m = require('./foo');
-
 module.exports = function (n) {
     return n * 100;
 };
diff --git a/test/deps.js b/test/deps.js
new file mode 100644
index 0000000..213a0f0
--- /dev/null
+++ b/test/deps.js
@@ -0,0 +1,42 @@
+var parser = require('../');
+var test = require('tap').test;
+var fs = require('fs');
+
+var files = {
+    main: __dirname + '/files/main.js',
+    foo: __dirname + '/files/foo.js',
+    bar: __dirname + '/files/bar.js'
+};
+
+var sources = Object.keys(files).reduce(function (acc, file) {
+    acc[file] = fs.readFileSync(files[file], 'utf8');
+    return acc;
+}, {});
+
+test('deps', function (t) {
+    t.plan(1);
+    var p = parser(files.main);
+    var rows = [];
+    
+    p.on('data', function (row) { rows.push(row) });
+    p.on('end', function () {
+        t.same(rows, [
+            {
+                id: files.main,
+                source: sources.main,
+                entry: true,
+                deps: { './foo': files.foo }
+            },
+            {
+                id: files.foo,
+                source: sources.foo,
+                deps: { './bar': files.bar }
+            },
+            {
+                id: files.bar,
+                source: sources.bar,
+                deps: {}
+            }
+        ]);
+    });
+});
diff --git a/example/files/bar.js b/test/files/bar.js
similarity index 67%
copy from example/files/bar.js
copy to test/files/bar.js
index 356a3ae..c57fa53 100644
--- a/example/files/bar.js
+++ b/test/files/bar.js
@@ -1,5 +1,3 @@
-var m = require('./foo');
-
 module.exports = function (n) {
     return n * 100;
 };
diff --git a/test/files/foo.js b/test/files/foo.js
new file mode 100644
index 0000000..c62e638
--- /dev/null
+++ b/test/files/foo.js
@@ -0,0 +1,5 @@
+var bar = require('./bar');
+
+module.exports = function (n) {
+    return n * 111 + bar(n);
+};
diff --git a/test/files/main.js b/test/files/main.js
new file mode 100644
index 0000000..8c71d79
--- /dev/null
+++ b/test/files/main.js
@@ -0,0 +1,2 @@
+var foo = require('./foo');
+console.log('main: ' + foo(5));
diff --git a/test/files/xyz.js b/test/files/xyz.js
new file mode 100644
index 0000000..dff6877
--- /dev/null
+++ b/test/files/xyz.js
@@ -0,0 +1,2 @@
+var foo = require('./foo');
+console.log('xyz: ' + foo(6));

-- 
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