Skip to content

Commit 009e2cf

Browse files
author
James Halliday
committed
update tests for the newer module-deps api
1 parent fdf508d commit 009e2cf

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

test/deps.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,14 @@ test('trust but verify', function (t) {
7676
}));
7777
bundle.pipe(packs[name]);
7878
});
79-
mdeps(files).pipe(fr)
79+
var md = mdeps();
80+
md.pipe(fr);
8081
fr.pipe(rowsOf(function (rows) {
8182
t.deepEqual(rows, expected.common);
8283
}));
8384
fr.pipe(packs.common);
85+
files.forEach(function (file) { md.write({ file: file }) });
86+
md.end();
8487
});
8588

8689
function rowsOf (cb) {
@@ -95,6 +98,7 @@ function read (name, ref) {
9598
if (!ref) ref = {};
9699
var file = norm(name);
97100
ref.id = file;
101+
ref.file = file;
98102
ref.source = fs.readFileSync(file, 'utf8');
99103
if (!ref.deps) ref.deps = {};
100104
return ref;

test/files.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,14 @@ test('more complicated dependencies', function (t) {
7979
}));
8080
bundle.pipe(packs[name]);
8181
});
82-
mdeps(files).pipe(fr)
82+
var md = mdeps();
83+
md.pipe(fr)
8384
fr.pipe(rowsOf(function (rows) {
8485
t.deepEqual(rows, expected.common);
8586
}));
8687
fr.pipe(packs.common);
88+
files.forEach(function (file) { md.write({ file: file }) });
89+
md.end();
8790
});
8891

8992
test('same module included twice', function (t) {
@@ -143,11 +146,14 @@ test('same module included twice', function (t) {
143146
}));
144147
bundle.pipe(packs[name]);
145148
});
146-
mdeps(files).pipe(fr)
149+
var md = mdeps();
150+
md.pipe(fr)
147151
fr.pipe(rowsOf(function (rows) {
148152
t.deepEqual(rows, expected.common);
149153
}));
150154
fr.pipe(packs.common);
155+
files.forEach(function (file) { md.write({ file: file }) });
156+
md.end();
151157
});
152158

153159
test('threshold function reorganizes bundles', function (t) {
@@ -233,11 +239,14 @@ test('threshold function reorganizes bundles', function (t) {
233239
}));
234240
bundle.pipe(packs[name]);
235241
});
236-
mdeps(files).pipe(fr)
242+
var md = mdeps();
243+
md.pipe(fr)
237244
fr.pipe(rowsOf(function (rows) {
238245
t.deepEqual(rows, expected.common);
239246
}));
240247
fr.pipe(packs.common);
248+
files.forEach(function (file) { md.write({ file: file }) });
249+
md.end();
241250
});
242251

243252
test('if dependent is in common, so is dependee', function (t) {
@@ -301,11 +310,14 @@ test('if dependent is in common, so is dependee', function (t) {
301310
}));
302311
bundle.pipe(packs[name]);
303312
});
304-
mdeps(files).pipe(fr)
313+
var md = mdeps();
314+
md.pipe(fr)
305315
fr.pipe(rowsOf(function (rows) {
306316
t.deepEqual(rows, expected.common);
307317
}));
308318
fr.pipe(packs.common);
319+
files.forEach(function (file) { md.write({ file: file }) });
320+
md.end();
309321
});
310322

311323
function rowsOf (cb) {
@@ -326,6 +338,7 @@ function read (name, ref) {
326338
if (!ref) ref = {};
327339
var file = norm(name);
328340
ref.id = file;
341+
ref.file = file;
329342
ref.source = fs.readFileSync(file, 'utf8');
330343
if (!ref.deps) ref.deps = {};
331344
return ref;

0 commit comments

Comments
 (0)