Sha256: 0f83695c50b77dc9fb1614a62b269c83d917c2bd58f11adc325cb999a3a46c73
Contents?: true
Size: 1.44 KB
Versions: 62
Compression:
Stored size: 1.44 KB
Contents
var fs = require("fs"); var path = require("path"); var rimraf = require("rimraf"); var watcherManager = require("../../lib/watcherManager"); function TestHelper(testdir) { this.testdir = testdir; var self = this; this.before = function(done) { self._before(done); }; this.after = function(done) { self._after(done); }; } module.exports = TestHelper; TestHelper.prototype._before = function before(done) { Object.keys(watcherManager.directoryWatchers).should.be.eql([]); this.tick(function() { rimraf.sync(this.testdir); fs.mkdirSync(this.testdir); done(); }.bind(this)); }; TestHelper.prototype._after = function after(done) { this.tick(function() { rimraf.sync(this.testdir); Object.keys(watcherManager.directoryWatchers).should.be.eql([]); done(); }.bind(this)); }; TestHelper.prototype.dir = function dir(name) { fs.mkdirSync(path.join(this.testdir, name)); }; TestHelper.prototype.file = function file(name) { fs.writeFileSync(path.join(this.testdir, name), Math.random() + "", "utf-8"); }; TestHelper.prototype.mtime = function mtime(name, mtime) { var stats = fs.statSync(path.join(this.testdir, name)); fs.utimesSync(path.join(this.testdir, name), stats.atime, new Date(mtime)); }; TestHelper.prototype.remove = function remove(name) { rimraf.sync(path.join(this.testdir, name)); }; TestHelper.prototype.tick = function tick(fn) { // setTimeout(fn, 100); setTimeout(function() { // console.log("tick"); fn(); }, 100); };
Version data entries
62 entries across 62 versions & 1 rubygems
Version | Path |
---|---|
smock-0.1.209 | node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js |
smock-0.1.208 | node_modules/webpack/node_modules/watchpack/test/helpers/TestHelper.js |