Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

failing test for watches

  • Loading branch information...
commit aeffd15bf51a6dd7685c8b5ed9f7bc05c15b0b6d 1 parent bb84845
@substack authored
Showing with 45 additions and 0 deletions.
  1. +45 −0 test/watch.js
View
45 test/watch.js
@@ -0,0 +1,45 @@
+var assert = require('assert');
+var browserify = require('browserify');
+var fileify = require('../');
+var vm = require('vm');
+var fs = require('fs');
+
+function write (file, x, cb) {
+ fs.writeFile(__dirname + '/watch/' + file, x.toString(), function (err) {
+ if (err) assert.fail(err)
+ else setTimeout(cb, 300)
+ });
+}
+
+exports.watch = function () {
+ try { fs.unlinkSync(__dirname + '/watch/x.txt') } catch (e) {}
+ try { fs.unlinkSync(__dirname + '/watch/y.txt') } catch (e) {}
+
+ var x0 = Math.random();
+ write('x.txt', x0, function () {
+ var b = browserify().use(
+ fileify('files', __dirname + '/watch', { watch : true })
+ );
+
+ var c0 = {};
+ vm.runInNewContext(b.bundle(), c0);
+ assert.deepEqual(c0.require('files', '/'), { 'x.txt' : x0 });
+
+ var x1 = Math.random();
+ write('x.txt', x1, function () {
+ var c1 = {};
+ vm.runInNewContext(b.bundle(), c1);
+ assert.deepEqual(c1.require('files', '/'), { 'x.txt' : x1 });
+
+ var y0 = Math.random();
+ write('y.txt', y0, function () {
+ var c2 = {};
+ vm.runInNewContext(b.bundle(), c2);
+ assert.deepEqual(c2.require('files', '/'), {
+ 'x.txt' : x1,
+ 'y.txt' : y0,
+ });
+ });
+ });
+ });
+};
Please sign in to comment.
Something went wrong with that request. Please try again.